亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

如何深度觀察angularjs中的數組?

如何深度觀察angularjs中的數組?

陪伴而非守候 2019-08-26 09:59:50
如何深度觀察angularjs中的數組?我的范圍中有一個對象數組,我想要觀察每個對象的所有值。這是我的代碼:function TodoCtrl($scope) {   $scope.columns = [       { field:'title', displayName: 'TITLE'},       { field: 'content', displayName: 'CONTENT' }   ];    $scope.$watch('columns', function(newVal) {        alert('columns changed');    });}但是當我修改值時,例如我TITLE改為TITLE2,alert('columns changed')從不彈出。如何深入觀察數組內的對象?有一個現場演示:http://jsfiddle.net/SYx9b/
查看完整描述

3 回答

?
拉風的咖菲貓

TA貢獻1995條經驗 獲得超2個贊

$scope.changePass = function(data){
    
    if(data.txtNewConfirmPassword !== data.txtNewPassword){
        $scope.confirmStatus = true;
    }else{
        $scope.confirmStatus = false;
    }};
  <form class="list" name="myForm">
      <label class="item item-input">        
        <input type="password" placeholder="???????????????????" ng-model="data.txtCurrentPassword" maxlength="5" required>
      </label>
      <label class="item item-input">
        <input type="password" placeholder="???????????????" ng-model="data.txtNewPassword" maxlength="5" ng-minlength="5" name="checknawPassword" ng-change="changePass(data)" required>
      </label>
      <label class="item item-input">
        <input type="password" placeholder="????????????????????????" ng-model="data.txtNewConfirmPassword" maxlength="5" ng-minlength="5" name="checkConfirmPassword" ng-change="changePass(data)" required>
      </label>      
       <div class="spacer" style="width: 300px; height: 5px;"></div> 
      <span style="color:red" ng-show="myForm.checknawPassword.$error.minlength || myForm.checkConfirmPassword.$error.minlength">??????????????????? 5 ????</span><br>
      <span ng-show="confirmStatus" style="color:red">?????????????????????</span>
      <br>
      <button class="button button-positive  button-block" ng-click="saveChangePass(data)" ng-disabled="myForm.$invalid || confirmStatus">???????</button>
    </form>


查看完整回答
反對 回復 2019-08-26
  • 3 回答
  • 0 關注
  • 605 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號