부모 범위에 저장된 부울 값을 기반으로 지시문을 조건부로 표시하려고합니다. 나는 왜 아래가 작동하지 않는지 이해할 수 없다. "작동하지 않음"이란 지시어가 표시되지 않음을 의미합니다.Angular JS : ng-switch on boolean이 작동하지 않습니다.
<ul class="nav navbar-nav pull-right" ng-switch="userIsAuthenticated">
<account-item item="accountMenuItem" ng-repeat="accountMenuItem in anonymousMenuItems" ng-switch-when="false"></account-item>
<account-item item="accountMenuItem" ng-repeat="accountMenuItem in authenticatedMenuItems" ng-switch-when="true"></account-item>
</ul>
어느 지침은 심지어 "userIsAuthenticated는"내 테스트 케이스에 '거짓'으로 설정되어 생각 표시됩니다. 지시문 위에 {{userIsAuthenticated}}
을 추가하면 'false'가 예상대로 출력됩니다.
나는 또한이 시도했습니다
<ul class="nav navbar-nav pull-right" ng-switch={{userIsAuthenticated}}>
<account-item item="accountMenuItem" ng-repeat="accountMenuItem in anonymousMenuItems" ng-switch-when={{false}}></account-item>
<account-item item="accountMenuItem" ng-repeat="accountMenuItem in authenticatedMenuItems" ng-switch-when={{true}}></account-item>
</ul>
나는 제거 할 경우 조건부 NG-스위치 때이 표시됩니다 지침 중 하나에서 속성. 그래서 문제가 내 스위치인지 알 수 있습니다. NG 스위치의
'account-item' 지시어에 표시 할 수 있습니까? – raina77ow