4

誰かがこれについて私を助けることができますか? 以下は私のコードと問題の説明です。

<table>
 <thead>
   <tr>
     <th>Icon</th>
     <th>Name</th>
     <th>Details</th>
   </tr>
 </thead>

 <tbody ng-repeat="category in editor.categories">
    <tr>
      <th>{{category.categoryName}}</th>
    </tr>
    <tr ng-repeat="feature in category.features"> // Question?
       <td>{{feature.iconImg}}</td>
       <td>{{feature.featureName}}</td>
       <td>{{feature.details}}</td>
     </tr>
     <tr ng-if="feature.id==1"> // condition 1
     </tr>
     <tr ng-if="feature.id==2"> // condition 2
     </tr>
  </tbody>
</table>

では、問題を説明しましょう。カテゴリのグループがあります。機能のグループとしてのすべてのカテゴリ。

ここで私の質問は、条件に基づいてすべてのカテゴリのこれらの機能を表示するにはどうすればよいかということng-ifです。つまり、<tr>条件 1 は の場合にのみ表示されfeature.id==1、条件 2 も同様に の場合にのみ表示されますfeature.id==2

Q.さまざまな条件に基づいて ng-if 条件を含めるにはどうすればよいですか?

よろしくお願いいたします。

4

2 に答える 2

3

ng-switch と ng-switch-when を確認してください

https://docs.angularjs.org/api/ng/directive/ngSwitch

よろしく

于 2015-09-08T10:11:27.007 に答える