[英]Angular select model not setting value
我有一個字符串數組,即帳號。 單擊表中的記錄時,我提供了一個模式來更新記錄,其中一個字段是帳號。 這顯示了一些正確的但似乎失去了與vm.accountNumber的雙向綁定,但也確實顯示了模型的值。
vm.accountNumber始終具有在單擊表行進行編輯時設置的值。 盡管有模型,但它永遠不會成為選擇。 我懷疑我失去了雙向鏈接,它正在為模型創建自己的變量。
<select class="ui search fluid selection dropdown" id="accountSearch" ng-model="vm.accountNumber">
<!--ng-options="account for account in vm.accounts.slice(1)">-->
<option ng-repeat="account in vm.accounts | limitTo: vm.accounts.length : 1" value="account" ng-selected="account == vm.accountNumber">{{account}}</option>
</select>
這是一個帳戶數組的片段。 0:“ - ”1:“0001”2:“0002”3:“0003”4:“0004”
我會說只使用ng-options
指令而不是ng-repeat
ing option
<select class="ui search fluid selection dropdown"
id="accountSearch" ng-model="vm.accountNumber"
ng-options="account for account in vm.accounts">
</select>
雖然我想指出你的問題是選項值屬性,
你應該改變
value="account"
至
value="{{account}}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.