我发现生成新的$ hashKey有问题。 在这段代码中:
this.list = '[{
"body": "asdf",
"tag": "resolved",
"time": "2147483647",
"id": "51"
}, {
"body": "asdf",
"tag": "undone",
"time": "2147483647",
"id": "138"
}, {
"body": "asdf",
"tag": "undone",
"time": "2147483647",
"id": "139"
}]';
this.addTask = function(body) {
newObj.body = body;
newObj.tag = 'undone';
newObj.time = Date.now();
this.list.push(newObj);
}
当我添加第二个对象时,它的$$ hashKey相同。我在ng-repeat
this.list
时遇到错误。
如何手动递增或有简单的解决方案?
答案 0 :(得分:1)
试试这个
this.addTask = function(body) {
var newObj = { body : body, tag :'undone', time: Date.now() };
this.list.push(newObj);
}