Why is my default switch not showing in the model?

I have a pre-selected radio button in the form. Here is the html:

<input type="radio" ng-model="bankAccount.selectedAccount" value="{{account.bankAccountId}}" class="radioChanged" ng-checked="{{account.defaultAccount}}">

A form will appear, and the switch will be selected as it should, but when I click the submit button, the model bankAccount.selectedAccountis just an empty object. If I click on the default switch that is already selected in the view, it will appear in the model. What do I need to do to populate my model with the default switch?

+4
source share
1 answer

ng-value value , . , ng-checked , , , "" , (If the expression is truthy, then special attribute "checked" will be set on the element).

Try: -

 <input type="radio" ng-model="bankAccount.selectedAccount" 
         ng-value="account.bankAccountId" class="radioChanged" 
         ng-checked="account.defaultAccount">

[select] input [radio], , ngModel .


ng-checked ng-model, ng-checked , /. ngModel. , , , ng-model bankAccount.selectedAccount .

: -

<input type="radio" ng-model="bankAccount.selectedAccount" 
     ng-value="account.bankAccountId" class="radioChanged" />

Plnkr

+1

All Articles