2014-10-17 2 views
0

Angular.js에서 팝업을 사용하려고하는 중입니다. 팝업을 제공하는 행의 특정 셀을 클릭하는 옵션이 있습니다 -쪽으로. 아래는 코드 스 니프입니다.Angular.JS : 팝업에 대한 각도로 데이터가 업데이트되지 않습니다.

HTML 코드

<table class="table table-bordered"> 
     <tr><th>Number</th><th>Comment</th></tr><tr ng-repeat="col in Data|filter:search1"><td>{{col.cd}}</td><td><div ng-controller="igCtrl"> 

    <a href="#" ng-click="addComment(col.cd)">Comment</a> 

    <ig-comment></ig-comment> 
</div></td></tr></table> 

컨트롤러이 테이블

function igCtrl($scope) { 
$scope.addComment = function (col) { 
$scope.cdn=""; 

       $scope.cdn = col; 



console.log("testing"+$scope.cdn); 
$scope.check = true; 
if ($scope.check) { 
       $("#comment").modal('show'); 

      }; 

};} 

지침

app.directive('igComment', function() { 

return { 
    restrict: 'E', 
    replace: true, 
template:'<div class="row"> 
<div class="modal fade" id="comment" aria-hidden = "true" > 
    <div class = "modal-dialog" style="width:300px;height:600px;"> 
      <form class="form-horizontal" name="form" ng-submit = "submit()" novalidate="novalidate"> 
       <div class = "modal-content" > 
        <div class = "modal-header"> 
         Data is :{{cdn}}  

         <input ng-disabled="form.$invalid" type="submit" class="btn btn-primary" id="submit" ng-click="submit()" value="Submit"></input > 
         <input type="button" class="btn btn-primary" data-dismiss="modal" value="Cancel" ng-click="cancel()"></input> 
        </div> 
       </div > 
      </form> 
     </div > 
    </div> 
</div>' 
}; 
}); 

데이터는 데이터베이스에서오고있다. 컨트롤러의 cdn 변수가 업데이트되고 컨트롤러의 console.log 문이 올바른 출력을 제공합니다.

그러나 지침의 cdn은 업데이트되지 않으므로 팝업에서 의식 결과가 표시되지 않습니다.

어떻게 수정합니까?

감사합니다.

답변

1

나는 이것을 위해 고립 된 범위를 사용하고자합니다. 예 : 미세 (불운을 무시

return { 
     restrict: 'E', 
     replace: true, 
     scope: { cdn: '=' } // this assigns the "cdn" from the directive attribute above 
          // to the directive isolated scope (under the same name) 
     ... 

나머지는 것 같다

<ig-comment cdn="cdn"></ig-comment> 

은 *이 컨트롤러의 범위

에서와 지시에서 "CDN"값을 취 jquery mix)와 작동해야합니다.

+0

감사합니다 :) 내 문제를 해결하지 못했지만 더 나은 이해를 위해 나를 도왔습니다. :) –