2013-07-03 3 views
2

예상 겨 반복 + 때 NG-스위치 - 다음 코드는 제대로 작동하지 않는 것 :AngularJS와 : =

<div ng-switch on="current"> 
    <div ng-repeat="solution in solutions" ng-switch-when="{{solution.title}}"> 
     {{solution.content}} 
    </div> 
</div> 

{{solution.title}}의 출력은 그대로 {{solution.title}}입니다. 각도로 처리되지 않습니다.

답변

6

ng-switch-when 태그에 상수가 필요하면 변수를 넣을 수 없습니다. 다음과 같이 코드를 다시 작성할 수 있습니다.

<div ng-repeat="solution in solutions"> 
    <div ng-show="current == solution"> 
     {{solution.content}} 
    </div> 
</div> 
+0

안녕하세요. 귀하의 답변 주셔서 감사하지만 그건 그것을 자르지 않습니다. 그것은 실제로 제가 시도한 첫 번째 것입니다. solution.title은 각도로도 처리되지 않습니다. –

+0

나는 내가 당신의 필요를 가지고 있기를 바란다. 나는 나의 대답을 편집했다. – remigio

+0

그래, 일하는 사람! 그러나 어떻게 내 버전이 잘못되었는지 보지 못하겠습니까?! –