2017-06-04 7 views
1

Angularとng-repeatを使用して、Ajax jsonからHTMLでテーブルをロードしようとしています。 私の問題は、JSONが少し複雑で、テーブルに表示したい "informationstyp"にアクセスする方法がわかりません。 JSONのルート( "values")はリストです。次のレベル(「informationstyper」)もリストです。角度とngリピートのAjax JSONからテーブルをロード

テーブルに「informationstyp」を取得するにはどうすればよいですか? {{data.arendeslagId}}の代わりに何を書き込むべきですか?私は私のテーブルに何をしたいです

は次のとおりです。

FK1002

FK1003

FK1004

はあなたの助けをいただき、ありがとうございます。

私のhtml:

 <table class="table table-hover"> 
      <thead> 
      <tr> 
       <th>Arendeslagid</th> 
      </tr> 
      </thead> 
      <tbody> 
      <tr ng-repeat="data in infotyper"> 
       <td>{{data.arendeslagId}}</td> 
      </tr> 
      </tbody> 
     </table> 

私はJavaScript:

$scope.infotyper = ""; 

    $scope.invoke = function() { 
     $.ajax({ 
       "cache": false, 
       "async": true, 
       "crossDomain": true, 
       "url": url", 
       "method": "POST", 
       "headers": { 
        "cache-control": "no-cache", 
       }, 
      success: function (response) { 
        $scope.infotyper= response; 
       } 
      }); 
     }; 

私のJSON応答:

enter image description here

+0

があなたの代わりにjQueryのAJAXの角度で$ HTTPサービスのメソッドを使用することができます要求します。 – hasan

+0

@hasanありがとう、私は今それを$ http – chichi

答えて

3

は、これを変更してください:

これに3210

success: function (response) { 
    $scope.infotyper= response.values; 
    $scope.$apply(); 
} 

あなたは、私は強くあなたがAJAXのための代わりにjQueryの$httpサービスを使用することをお勧めAngularJSを使用している場合は、

+0

に変更しました。それもうまくいきません。 JSONの次のレベル(「informationstyper」)にはどうすれば到達できますか? – chichi

+0

$ scopeに対して1つの議決権があります。$ apply() – chichi

+0

そのフィールドは配列です。だから、これらの要素の中でサイクリングのためにもう一度ng-repeatが必要です。例えば: ' ​​{{data.arendeslagId}} <= "data.informationstyperでタイパー" TDのNGリピート> {{}} typer.informationstyp ' – quirimmo