我目前正在处理一个可以从json对象获取值的表单。我已经完成了! (是的〜)但是当我发布值时,我无法得到任何东西。在POST后,value =“{{key}}”不返回实际数据。任何机构都可以帮助我解决这个问题?非常感谢!
<form class="form-horizontal" role="form" name="firewallForm" novalidate ng-init="firewallInit()">
<div class="form-group">
<label class="col-sm-1 control-label" for="firewallSource">Source</label>
<div class="col-sm-4 col-lg-2 col-md-2" ng-controller="entitiesController">
<select class="form-control input-medium" ng-model="firewallSource" ng-required="true">
<option value="" disabled selected> Enter Source Entity</option>
<option ng-repeat="(key, value) in entities.entities" value="{{key}}">{{key}}</option>
</select>
</div>
</div><div class="form-group">
<div class="col-sm-10">
<button type="button" class="btn btn-default" ng-click="submitFormFirewall()">
Submit
</button>
</div>
</div>
</form>
我的JS看起来像:
$scope.submitFormFirewall = function() {
var postData = {};
postData["index"] = $scope.firewallRuleID;
postData["to"] = $scope.firewallDestination;
postData["application"] = $scope.firewallApplication;
postData["action"] = $scope.firewallAction;
postData["from"] = $scope.firewallSource;
答案 0 :(得分:0)
试试这个:
<select ng-model="firewallSource" ng-options="obj.key as obj.value for obj in entities.entities">
<option value=""> Enter Source Entity</option>
</select>
key
和value
实际上是entities[0]
对象