2014-04-23 2 views
0
{{$$addFunc='isAdd'}} 
<span ng-repeat="listItem in stmt.content"> 
    <span ng-switch on="listItem.meta.category"> 
     <span ng-switch-when="plain" ng-bind-template="{{listItem.content}}"> 
     </span> 
     <span ng-switch-when="link"> 
      <a href="{{listItem.content.lnk}}">{{listItem.content.cap}}</a> 
     </span> 
     <span ng-switch-when="list" ng-init="{{$$addFunc='isInsert'}}">{{$$addFunc}}</span> 
    </span> 
</span> 
{{$$addFunc}} 

$$ addFunc를 수정하는 방법은 'isInsert'입니까?ng-repeat에서 값을 변경하고 ng-repeat에서 표시하는 방법

+0

변경'<스팬 ng-switch on = "listItem.meta.category">'~'' –

+0

더 잘 설명해야합니다. 정확히 여기서 무슨 일이 일어나는지 모르겠다. –

답변

0

변수 값을 설정하기 위해 {{}} 보간이 필요하지 않습니다.

ng-init="$$addFunc='isInsert'"


당신이 $$addFunc를 업데이트해야 또 다른 문제는 ng-switchchild scope를 생성하는 것입니다 : ng-init은 일반 식을합니다. 이 범위는 $$addFunc를 업데이트 할 수 있도록, 당신은 객체로 이동해야합니다

$scope.operation = { 
    $$addFunc: 'isAdd' 
}; 

그리고 이런 식으로 업데이트 :

<span ng-switch-when="list" ng-init="operation.$$addFunc='isInsert'"> 
다음

작동하는 데모입니다 : http://plnkr.co/edit/Alypsqu1bSCwCqko4F8m?p=preview

관련 문제