单击按钮更改json中的值
Change value in json on buttonclick
我在buttonclick中有一个buttonclic。我的警报在自动取款机上工作。
$scope.getid = function (order) {
$scope.chosen.id = order.id;
$scope.chosen.status = order.point;
$scope.start = function (time) {
alert(order.point)
}
};
我想更改订单.point并给它一个新的值
$scope.start = function (time) {
(new value)
order.point = ('2')
}
提前感谢
正如@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>
相关文章:
- 单击按钮更改加载到表中的JSON文件
- 如何用HTML中的JSON外部文件填充下拉按钮
- 单击按钮即可显示带有提取的json数据的表
- 在“加载更多”按钮函数中包含 JSON 数据
- 点击浏览器的“后退”按钮显示的是JSON而不是HTML(使用Rails和d3.js)
- 尝试从单选按钮显示的JSON数组中调用多个对象
- dojo-dgrid带有store from url(json数据)重载/刷新按钮
- 从JSON模式创建表单,如何添加关闭按钮
- 使用JSON的javascript中的ASP.NET按钮单击事件
- 单击按钮时使用JS读取JSON文件
- 我有一个json文件,当我点击按钮时
- 使用 Json 如何根据数据库中的值选择单选按钮
- 尝试在JavaScript中制作下一步按钮以显示JSON数组
- 从 JSON Href 获取在表中工作的按钮
- 如何在 Angular JS 中使用 JSON 动态选择单选按钮
- 像地图按钮一样反应.JSON 数据
- 如何通过单击Angular.js中自定义目录中的按钮来调用特定用户JSON数据
- 使用javascript和jquery将“下一个”和“上一个”按钮添加到来自JSON的HTML5音频播放器
- 当 JSON 返回某个值时,更改 AJAX 中按钮的值
- 如何设置按钮以使用 jQuery、AJAX、JSON 和 MVC 调用不同的按钮