1
我有一个包含字符串数组属性字段:在angularjs NG-模型的动态创建
在控制器我有:
$scope.data = {};
$scope.fields = [
"new0.name",
"new0.type",
"new0.address",
"new0.city",
"new0.postalCode"
];
鉴于我有:
<div class="control-group" ng-repeat="f in fields">
<label class="control-label">Some field name</label>
<div class="controls">
<input type="text" name="{{f}}" ng-model="data.f" class="input-xlarge">
</div>
</div>
在ng-repeat,如何将f的值连接到ng-model
以获得,例如ng-model =“ data.new0.name“?
忽略下面我的回答,你试图'数据并[f]' – tymeJV
@tymeJV数据并[f]是溶液。谢谢! – eomeroff
发表了一个简单的答案,让它变得太复杂了:) – tymeJV