下面是代碼:NG-模型中選擇不與工作納克提交
HTML
<form ng-submit="fun()">
<select ng-model="a" ng-options="table.id as table.name for table in tables></select>
<input type="text" ng-model="b">hello</input>
<input type="submit">Ok</input>
</form>
JS
$scope.tables = [{"id":1, "name":"x"},{"id":2, "name":"y"},{"id":3, "name":"z"}];
//This is dummy data, tables is actually coming from another custom API
$scope.fun = function(){
console.log($scope.a);
console.log($scope.b);
}
這是輸出:
undefined
hello
當我檢查源代碼時,選項將追加到我的選擇看起來像這樣:
<option label="x" value="undefined:undefined"></option>
我怎樣才能在ng-submit控制器中選擇選項?
提供表DAT一個 – 2017-04-05 09:11:05
你不附加任何選擇選擇。 –
當您呈現HTML時,您可以在下拉列表中看到哪些選項? – cezar