ここで私は、動的に、私はNG-モデルのタイプの値を設定したいng-repeat
例えばanglejsのng-modelに動的に値を与える方法は?
<div ng-repeat="type in types">
<input type="checkbox" ng-model="{{type}}" />{{ type }}
</div>
を使用してHTML要素を生成しています。
function DynamicController($scope) {
$scope.types = [
"typeOne",
"typeTwo",
"typeThree"
];
$scope.typeValues = {};
};
<div ng-app ng-controller="DynamicController">
<div ng-repeat="type in types">
<input type="checkbox" ng-model="typeValues[type]" ng-click="show()" /> {{ type }}
</div>
<h3>Values</h3>
<div ng-repeat="type in types">
{{ type }} : {{ typeValues[type] }}
</div>
</div>
を次のようにあなたは$スコープのプロパティの1つに動的な値を格納することができ、それが可能であるか、他の私は、この
<div ng-repeat="type in types">
<input type="checkbox" ng-model="{{type}}" ng-true-value="{{type}}" />{{ type }}
</div>
スコープ内で関数を使用する場合、 '$ parent.myFunc()'も連鎖され、パラメータに '$ parent.myFunc(val).cost'が渡されます –