1 回答
TA贡献1934条经验 获得超2个赞
送你一句话:this != $scope。
尝试修改成这样:
$scope.reset=function(){
var sum=0;
$scope.thinglist.forEach(function (item,index){
if(!item.isDone){
sum++;
}
})
$scope.many=sum;
// $scope.$apply();
console.log(this.many);
}
$scope.add=function(ei){
// console.log(this)
$scope.thinglist.push({
text:this.thing,
isDone:false
});
$scope.thing="";
// this.many++;
$scope.reset();
// console.log(this.thinglist);
}
$scope.do=function(index){
// console.log(this);
// this.many=this.many-1;
$scope.thinglist[index].isDone=!$scope.thinglist[index].isDone;
$scope.reset();
// $emit('reset');
// console.log($scope.$digest)
// this.$digest();
// console.log(this.many);
// $scope.$apply;
}
添加回答
举报