2016-10-19 1 views
0

私は角に問題があります。最初にデータを取得するデータテーブルで2つのネストされたng-repeatを使用したい、2番目にはフィールドの名前を取得しますここで(最初のNGリピートで検索)データ
から取得すると、私はコードを実行しようとしたものである:例えば
ネストされたng-repeatは、1つは他のものに依存する

<table md-table flex-order-gt-sm > 
    <thead md-head> 
    <tr md-row > 
    //1st : get the name of fields, not a problem 
     <th md-column ng-repeat="field in fields">{{item.name}}</th> 
      </tr> 
    </thead> 
    <tbody md-body> 
     <tr md-row ng-repeat="item in items"> 
      <td md-cell ng-repeat="field in fields" > 
    //here is the problem I want to get the item that it's field name is field 
        {{item.{{field}} }}</td> 
       </tr> 
      </tbody> 
     </table> 

フィールドが含まれている場合:{「A」、「B」、」 c '}
と項目には{' a ':' 1 '、' b ':' 2 '、' c ':' 3 '}が含まれます。
Iは、スコープ・オブジェクトのスコープデータをretireveするtoString()を使用する1

+0

ここでドット表記ではなくブラケット表記を使用する必要があります。 {{item **。** [field.name.toString()]}} 'を試したときに、私が探しているように思われる' {{item [field]}} '' – Claies

答えて

2

を返す{{アイテム{{フィールド}}}}の第1の反復のために、例えばたい。

<td md-cell ng-repeat="field in fields | filter: { name: 'field' }">     
</td> 
+0

私はエラーが発生します – aName

+0

'.'の必要性、plunkerを確認してください。 – Sravan

+0

なぜあなたは 'field.name'をもう一度受け取りましたか?あなたは疑問に抱きません。 – Sravan

0

フィールドコレクションからフィールドを取得することができます {{フィールド}}

+0

それも正しいようですが、私は逆、アイテムのアイテムが必要と思う|フィルタ:{名前:フィールド} 'ですが、項目が1番目でフィールドが2番目であるため、項目にこれを使用できます(フィールドはまだ存在しないため) – aName

0

あなたは

getFieldsByItem(アイテムの後のアイテムのコレクションの項目に応じてフィールドのコレクションを取得する必要があります:あなたはまた、フィルタを使用することができます別の方法として

<tr md-row ng-repeat="item in items"> 
    <td md-cell ng-repeat="field in fields" > 
     {{item[field.toString()]}} 
    </td> 
</tr> 

HEre is the plunker

関連する問題