第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

angular中ng-click事件

angular中ng-click事件

臨摹微笑 2018-11-10 15:11:57
我在ng-click事件中修改了$scope,為什么頁面部分被修改的數(shù)據(jù)沒有重新渲染<ol>        <li  ng-repeat="(index,obj) in thinglist" ng-class="{done:obj.isDone}" ng-click="do(index)">{{ obj.text }}      <button ng-click="delete(index)"> X</button>  </li>     </ol>在reset方法里面我設(shè)置了修改many的值,每次調(diào)用下面的do和add的時候,只有add會重新渲染頁面.
查看完整描述

1 回答

?
撒科打諢

TA貢獻(xiàn)1934條經(jīng)驗 獲得超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;

                

            }


查看完整回答
反對 回復(fù) 2018-12-03
  • 1 回答
  • 0 關(guān)注
  • 1131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號