2014-10-09 39 views
0

我有一個buttonclick按鈕點擊。 我的警報工程atm。更改json上buttonClick的值

 $scope.getid = function (order) { 

      $scope.chosen.id = order.id; 
      $scope.chosen.status = order.point; 

      $scope.start = function (time) { 
       alert(order.point) 
      } 



     }; 

我想改變order.point並給它一個新的價值

  $scope.start = function (time) { 
       (new value) 
       order.point = ('2') 
      } 

預先感謝您

+4

我不明白你的問題。你能詳細說明一下嗎? – karlingen 2014-10-09 12:22:33

+0

我更新了這個問題,希望你現在明白 – adam 2014-10-09 12:29:12

+0

關於HTML位是什麼? – sylwester 2014-10-09 12:32:52

回答

1

正如@karlingen提到我還沒有正確理解你的問題,你不能在另一個函數中添加一個函數。但事實上,如果你想改變的點擊動作angularjs json的值,你可以做這樣的

JSFiddle

var app = angular.module('myApp', []); 
 
app.controller('Controller', function ($scope) { 
 
    $scope.start = function (records) { 
 
     alert(records.col1); 
 
     records.col1 = 'test1'; 
 
     alert(JSON.stringify($scope.records)); 
 
     
 
    } 
 
    $scope.records = { 
 
     col1: 'a1', 
 
     col2: 'd1' 
 
    }; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div ng-app='myApp' ng-controller="Controller"> 
 
    <button ng-click="start(records)">Change</button> 
 
</div>

+0

非常感謝你,我只是用這條線records.col1 ='test1';它支付給我 – adam 2014-10-09 12:46:57

+0

如果我想將新值保存到json中。 $ http.post(「localhost」),我如何包含參數? – adam 2014-10-09 14:53:30