2014-11-06 5 views
0

내 문제는 ng-if는 내가 가장하는 것처럼 행동하지 않는다는 것입니다. _name 속성을 가진 객체의 배열을 가지고 있으며, ng-repeat를 만드는 메신저와 그 안의 일부를 구분하고 싶습니다. 특별한 방법으로 명명 된 것입니다. 그 메신저를 기반으로 내 ng-if를 만들었지 만 두 번이나 행의 내용을 인쇄해야합니다. 둘 중 하나 여야합니다. tksng-if 각도가 작동하지 않는다면

아래에는 clusterEntity.cluster의 배열이 있습니다. 두 번째 ng-if 논리 AND가 아닌 OR를 사용한다

 locations:{ 
      location:[ 
      {_name: "staging", _path: ""}, 
      {_name: "temp", _path: ""}, 
      {_name: "working", _path: ""} 
      ] 
     }, 

<div ng-repeat="location in clusterEntity.cluster.locations.location"> 

    <div ng-if=" 
       location._name === 'staging' || 
       location._name === 'working' || 
       location._name === 'temp'"> 
     <something here> 
    </div> 


    <div ng-if=" 
       location._name !== 'staging' || 
       location._name !== 'working' || 
       location._name !== 'temp'"> 

     <something there> 
    </div> 
    </div> 

답변

3

:와 동일

<div class="row" ng-if="location._name !== 'staging' && location._name !== 'working' && location._name !== 'temp'"> 

: 당신은 대신 ng-switch을 사용할 수

<div class="row" ng-if="!(location._name === 'staging' || location._name === 'working' || location._name === 'temp')"> 

, 그러나 당신의 코드는 않을 것 훨씬 짧아.

+0

예, 감사합니다. 나는 이미 ng-repeat를 비난하고 있었다 : / –