我需要从表单到控制器获取数组值,但无法找到方法。
HTML表单:
<div class="input-wrap">
<label>CNC Location</label>
<div class="input-inner">
<div class="input-area input-row">
<input type="text" id="latitude" name="locationLat" ng-model="actorData.cncLocation['lat']" placeholder="Latitude">
<input type="text" id="longitude" name="locationLong" ng-model="actorData.cncLocation['long']" placeholder="Longitude">
<input type="text" id="location-name" name="locationName" ng-model="actorData.cncLocation['name']" placeholder="Name">
</div>
<div class="buttons-area">
<a href class="remove-row"><i class="fa fa-minus-square"></i></a>
<a href class="add-row" ng-click="addRow()"><i class="fa fa-plus-square"></i></a>
</div>
</div>
<div ng-messages="actorForm.cncLocation.$dirty && actorForm.cncLocation.$error">
<span class="error-msg" ng-message="required">Required</span>
</div>
</div>
控制器:
angular.forEach($scope.actorData.cncLocation, function(){
$scope.cncLocation.push($scope.actorData.cncLocation);
console.log($scope.cncLocation);
});
我需要使用包含{"lat": "", "long":"", "name":""}
的对象发送cncLocation数组,用户可以在其中添加和删除行。