设置AngularJs Selector

时间:2017-06-13 11:54:25

标签: angularjs

当我尝试在angularJS选择器中设置初始值时,它会返回&#34;空白&#34; 元素,其值为"<option value="? number:1000139 ?">

如何设置默认值,而不会将其设置为某些乱码。

我的选择器如下所示:

<select ng-model="dataToCheckForImport.importContractId" ng-init="dataToCheckForImport.importContractId=opt.selectedContract">
   <option ng-selected="{{option.contract.kontraktID == dataToCheckForImport.importContractId}}" value="{{option.contract.kontraktID}}" ng-repeat="option in opt.allContracts">{{option.contract.kontraktID}} </option>
   <option value="-1">In Column</option>
 </select>

这是我获得的输出: enter image description here

我已经尝试将其设置为字符串,这只会使我的输出具有&#34;字符串格式&#34;比如"<option value="? string:1000139 ?">

我做错了什么?

1 个答案:

答案 0 :(得分:0)

Anyone finding this, the problem is when types do not match each other. in my example i tried to initialize my selector with a string and not a number as every other option is a number. Making all value "strings" solved my problem. also covered in this question:
Angular adds strange options into select element when setting model value