如果条件相同,则在ng-show中仅显示一个值

时间:2017-01-30 08:15:32

标签: angularjs

显示,它按语言显示结果。假设myAngApp1.value中有英语,它将显示英语。但在SharePoint列表中,所有四种语言都有英文值,因此它显示结果4次。 我的要求是如果myAngApp1.value等于英语,则它不应该显示4次英语。

              <span ng-show = "(customer.GLAcctLongTextEN).indexOf(myAngApp1.value)!=-1"> 
                {{customer.GLAcctLongTextEN}}
             </span>
              <span ng-show = "(customer.GLAcctLongTextPT).indexOf(myAngApp1.value)!=-1">    
                {{customer.GLAcctLongTextPT}}
             </span>

              <span ng-show = "(customer.GLAcctLongTextES).indexOf(myAngApp1.value)!=-1">    
                {{customer.GLAcctLongTextES}}
             </span>
              <span ng-show = "(customer.GLAcctLongTextZH).indexOf(myAngApp1.value)!=-1">    
                {{customer.GLAcctLongTextZH}}
             </span>
              <span ng-show = "(customer.GCoAGLcode).indexOf(myAngApp1.value)!=-1">  
                {{customer.GLAcctLongTextEN}}
             </span>
             <span ng-show = "(customer.Title).indexOf(myAngApp1.value)!=-1" >    
                {{customer.GLAcctLongTextEN}}
             </span>
         </td>   

1 个答案:

答案 0 :(得分:0)

使用ng-switch。下面是示例代码。

<p ng-switch="status">
    <span ng-switch-when="wrong">
       Wrong
    </span>
    <span ng-switch-default>
       Correct
    </span>
</p>