当使用文本框进行两次嵌套的ng-repeat时,不幸的是两个数据绑定不起作用。第一个具有prop的层次结构但传感器中的第二个层次没有将值绑定回模型。
可以在http://wotcloudclient.azurewebsites.net/#/Thing/Create下调用受影响的页面 用户:瓦格纳 密码:测试
提前致谢
<div class="well" ng-repeat="prop in properties">
<div class="form-group form-inline">
<h4 ng-show="prop.isMainThing">General</h4>
<input type="text" class="form-control" ng-model="prop.name" placeholder="Name" ng-show="!prop.isMainThing" required>
<input type="text" class="form-control" ng-model="prop.description" placeholder="Description" ng-show="!prop.isMainThing">
<button class="btn btn-danger btn-sm" ng-click="removeThing(prop)" ng-show="!prop.isMainThing"><span class="glyphicon glyphicon-trash"></span> </button>
</div>
<div class="form-group form-inline" ng-repeat="sensor in prop.sensors" style="margin-left: 20px">
<input type="text" class="form-control input-sm" ng-model="sensor.name" placeholder="Sensor name" required>
<select class="form-control input-sm" ng-model="sensor.datatype" ng-options="item.id as item.name for item in datatypes">
</select>
<button class="btn btn-danger btn-sm" ng-click="removeSensor(prop, sensor)"><span class="glyphicon glyphicon-trash"></span> </button>
</div>
<div class="form-group">
<button class="btn btn-primary btn-sm" ng-click="addNewSensor(prop)"><span class="glyphicon glyphicon-plus"></span> <span>Add Sensor</span></button>
</div>
</div>
答案 0 :(得分:0)
传感器阵列似乎是一个数组数组,每个传感器都是一个包含一个对象的数组。如果将传感器更改为对象数组或将代码更改为:
sensor.property - &gt;传感器[0] .property
<input type="text" class="form-control input-sm" ng-model="sensor[0].name" placeholder="Sensor name" required>
它应该有效,正如评论中所写,如果你证明了一个掠夺者,它会更容易帮助你。