我将使用 AngularJS 创建一个站点。
这是我的数组:
```html
非常感谢你。
这是我的数组:
```html
...
```$scope.replyList = [
{
"id": "85485",
"reply_content": "aaaaaaa",
"reply_gender": "1",
"reply_author": "John"
},
{
"id": "85487",
"reply_content": "bbbbbbb",
"reply_gender": "1",
"reply_author": "Ben"
},
{
"id": "85504",
"reply_content": "ccccccc",
"reply_gender": "1",
"reply_author": "Wang"
}
]
我想要做的是通过给定的键id
更新项目值。
例如,我想要更新id为85485
的内容。你该怎么处理?
$scope.replyList[{id: 85475}].reply_content = 'dddddd'; /* failed */
非常感谢你。
var obj = $scope.replyList.find(function(v) { return v.id == 85475; }); obj && obj.reply_content = 'dddddd';
- Pranav C Balan