我正在通过获取用户的输入来创建新用户。用户可以从下拉菜单中选择其状态。当用户选择状态时,我想保存状态ID而不是状态名称。如何为newSiteObj.st模型分配状态ID。
modalStates = [0:{id:53,name:“ A”},1:{zid:56,zn:“ B”}]
<div>
<label>Name</label>
<input name="name" ng-model="newObj.name" class="form-control" type="text" placeholder="Enter Name">
</div>
<div>
<label>State</label>
<select class="form-control selectpicker" name="state" data-live-search="true" data-live-search-placeholder="Search State" ng-model="newSiteObj.st">
<option value="">Select State</option>
<option ng-repeat="state in modalStates" value="{{state.id}}">{{state.name}}</option>
</select>
</div>
答案 0 :(得分:0)
您无法将选择绑定到属性,请尝试
ng-model="newSiteObjectState"