私は学校プロジェクトに取り組んでいます。 ng-repeatでいくつかの行を作成しました。私は「addElementsByClassName」でそれらを追加したい場合は今にarrayLengthはまだこれは私のhtmlである0繰り返し要素を角度に配列に追加する方法
次のようになります。
<tr class = "ingredient" ng-repeat = "i in data.Ingredients">
<td>{{ i.Ingredient.Name }}</td>
<td>{{ i.Ingredient.Amount_g }}</td>
</tr>
これは私のコントローラである:私が欲しい
$scope.allIngredients = [];
$scope.dashboard = MainService.getDashboard();
$scope.dashboard.then (function (data) { //receive the data from a server via MainService
$scope.data = data;
$scope.allIngredientRows = document.getElementsByClassName ('ingredient');
console.log ($scope.allIngredients.length);
});
その配列の中に私の行があるので、後でそれらと何かできるのです。しかし、配列の長さは0のままです。
document.getElementsByClassName( '原料')は、クラス成分を持つすべての要素の配列を提供します。 – Deep
そうですが、データではなく行を変更したいのですが、サービス関数呼び出しの応答データを確認する必要があります。 – JordyM
あなたのデータオブジェクトはどんなものですか? – IAmDranged