ng-repeat
ユーザーがアイテムの数を変更できるダイナミックがあります。
簡略化された JS:
$scope.items = [1, 2, 3, 4];
$scope.getBoxBackgroundColor = function () { return '#FF0000'; }
$scope.addItem = function () { $scope.items.push($scope.items.length + 1); }
HTML:
<div ng-repeat="item in items" ng-style="{ 'backgroundColor': getBoxBackgroundColor() }"></div>
<button ng-click="addItem()">Add Item</button>
問題:
新しいアイテムが追加されたときに、ディレクティブが関数を呼び出しng-style
ていません。getBoxBackgroundColor
なにか提案を?
ありがとう!