2017-02-14 7 views
0

を使用するテーブルでは再解析されません。モデルからのプッシュされたデータは、最初のテーブルに反映されません。それはコンソールにあります。フィドルリンクが付いてこれで私を助けてください。
フィドルリンク---- http://jsfiddle.net/8MVLJ/2649/プッシュされたデータは、角度

html========= 

<script src="https://code.angularjs.org/1.4.9/angular.min.js"></script> 
<script src="https://rawgit.com/dwmkerr/angular-modal-service/master/dst/angular-modal-service.js"></script> 

<div class="container" ng-app="app" ng-controller="Controller"> 
    <div class="row"> 
    <div class="col-xs-12"> 
     <table class="table table-striped table-bordered"> 
     <thead> 
      <th>Attribute Name</th> 
      <th>Attribute Value</th> 
     </thead> 
     <tbody> 
      <tr ng-repeat="newdetail in newDetails"> 
      <td> 
       <p ng-model="detail">{{newdetail.attrName}} </p> 
      </td> 
      <td> 
       <p ng-model="detailValue">{{newdetail.userAttrValue}} </p> 
      </td> 
      </tr> 
     </tbody> 
     </table> 
     <a class="btn btn-default" href ng-click="show()">Select Attribute</a> 

     <script type="text/ng-template" id="modal.html"> 
     <div class=" ngdialog-messsage modal fade"> 
      <div class="modal-dialog"> 
      <div class="modal-content"> 
       <div class="modal-header"> 
       <button type="button" class="close" ng-click="close('Cancel')" data-dismiss="modal" aria-hidden="true">&times;</button> 
       </div> 
       <div class="modal-body"> 
       <div class="row"> 
        <div class="col-xs-12"> 
        <table class="table table-striped table-bordered"> 
         <thead> 
         <th> 
          <input type="checkbox" ng-model="allSelected" ng-model-options="{getterSetter: true}"> 
         </th> 
         <th>Attribute Name</th> 
         <th>Attribute Value</th> 
         </thead> 
         <tbody> 
         <tr ng-repeat="detail in details"> 
          <td> 
          <input type="checkbox" ng-model="detail.Selected"> 
          </td> 
          <td> 
          <p ng-model="detail">{{detail.attrName}}</p> 
          </td> 
          <td> 
          <select ng-model="detail.user_attr_value" ng-init="detail.user_attr_value=detail.attr_value_Ind.split(',')[0]" class="form-control full-width"> 
           <option ng-repeat="option in detail .attr_value_Ind.split(',')" value="{{option}}">{{option}}</option> 
          </select> 
          </td> 
         </tr> 
         </tbody> 
        </table> 
        </div> 
       </div> 
       </div> 
       <div class="modal-footer"> 
       <div class="form-group"> 
        <input type="button" class="btn btn-primary" value="Add Selected" ng-click="add();close('Cancel')"> 
        <input type="button" class="btn btn-danger " ng-click="checkAll(details.length)" value="Clear"> 
       </div> 
       </div> 
      </div> 
      </div> 
     </div> 
     </script> 

    </div> 
    </div> 
</div> 

js=================== 


var app = angular.module('app', ['angularModalService']); 

app.controller('Controller', function($scope, $element, ModalService) { 
    $scope.newDetails = [{ 

    "attrName": "userType", 

    "userAttrValue": "Customer", 
    "userOrGroupId": "aaaazzz8522", 

    }]; 

    $scope.add = function() { 
    angular.forEach($scope.details, function(detail) { 
     if (detail.Selected == true) { 

     $scope.newDetails.push({ 

      'attrName': detail.attrName, 
      'attrName': detail.user_attr_value 
     }); 


     $element.modal('hide'); 
     close($scope.newDetails, 500); 
     console.log("loop", $scope.newDetails); 
      } 
    }); 

    }; 

    $scope.show = function() { 
    ModalService.showModal({ 
     templateUrl: 'modal.html', 
     controller: "Controller" 
    }).then(function(modal) { 
     modal.element.modal(); 
     modal.close.then(function(result) {}); 
    }); 
    }; 


    //================================================= 
    $scope.close = function(result) { 
    close(result, 600); 
    }; 
    $scope.details = [{ 

    "attrName": "region", 
    "attrType": "USER", 
    "attr_value_Ind": "CHN-N,CHN-S,CHN-C", 
    "buId": "DEFAULT", 

    }]; 
    var getAllSelected = function() { 
    var selecteddetails = $scope.details.filter(function(detail) { 
     return detail.Selected; 
    }); 

    return selecteddetails.length === $scope.details.length; 
    } 

    var setAllSelected = function(value) { 
    angular.forEach($scope.details, function(detail) { 
     detail.Selected = value; 
    }); 
    } 

    $scope.allSelected = function(value) { 
    if (value !== undefined) { 
     return setAllSelected(value); 
    } else { 
     return getAllSelected(); 
    } 
    } 
    $scope.checkAll = function(Count) { 
    angular.forEach($scope.details, function(details) { 

     details.Selected = false; 
    }); 

    }; 


}); 

答えて

0

私がチェックし、確認してくださいあなたのフィドルを更新しました。 http://jsfiddle.net/8MVLJ/2652/

あなたがあなたのモーダルコントローラで範囲を渡しているので、それが価値だプッシュし、この

ModalService.showModal({ 
     templateUrl: 'modal.html', 
     controller: "Controller", 
     scope:$scope <-- added here scope 
    }).then(function(modal) { 
     modal.element.modal(); 
     modal.close.then(function(result) {}); 
    }); 

のような親スコープを設定し、この

$scope.$parent.newDetails.push({  <-- added $parent here 
    'attrName': detail.attrName, 
    'userAttrValue': detail.user_attr_value 
}); 
+0

のようなあなたの価値をプッシュする$親を追加していないはあなたに感謝しますそんなに、その作業 – user7561080

関連する問題