2015-05-25 58 views
1

一個的選擇由AngularJs

 <select class="form-control" 
        name="accounts" 
        ng-model="vm.deposit.account" 
        ng-options="account.account as account.agency for account in vm.accounts" 
        required> 
      </select> 

需要的是嘗試的類型「選擇」。我試過使用ng-select,但不成功。

回答

0

在控制器,只需設置

vm.deposit.account = vm.accounts [0] .account; //或任何活動帳戶應該是

1

一種可能性是初始化你的模型在你的控制器或使用NG-INIT

vm.deposit.account = vm.accounts[0].account; 
+0

這將是這樣呢? NG-的init =「vm.deposit.account = vm.accounts [0] .account」 我已經嘗試過這種方式,而不是選擇 –

+0

你可以嘗試在你的控制器,但通常NG-的init應該工作 –

+0

我嘗試,但未選中。 –