我正在尝试更新$ scope内的数组。例如
$scope.data = [{detail:{name: "...", cred:"...."}, date:"current date"},...];
$scope.update = function(){
$scope.data[0].date = "new date";
}
但价值没有更新。我做错了吗?
答案 0 :(得分:0)
$scope.data = [{detail:{name: "...", cred:"...."}, date:"current date"},...];
$scope.update = function(){
$scope.data[0].date = "new date";
}
嗨,有时上面的角度视图可能无法直接反映更改,因此要实现此目的,请使用$ watch或$ watchCollection;
$scope.$watchCollection('data', function(value){
$scope.data = value;
});