1

I have this dropdown

<select class="form-control" ng-model="LoanDetailsVM.PaymentPeriodMonths">
           <option value="1">Monthly</option>
           <option value="3">Quarterly</option>
 </select>

The LoanDetailsVM.PaymentPeriodMonths can be either 1 or 3, but the proper option is not selected when I'm opening the page.

Is there anything else I need to add in order for the correct option to be selected?

1 Answer 1

1

You should use [(ngModel)] instead of ng-model and [ngValue] instead of value:

<select class="form-control" [(ngModel)]="LoanDetailsVM.PaymentPeriodMonths">
       <option [ngValue]="1">Monthly</option>
       <option [ngValue]="3">Quarterly</option>
</select>
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, you're right, I'll accept your answer in 8 minutes.
@Laziale You're welcome. And it is unclear whether you are asking about Angular 2 or AngularJS, those are two totally different things, please make sure that is clear in your future questions.
AngularJS only, not Angular2 ATM. Thx
@Laziale Well, I am not sure that this works then, I've never used AngularJS, only Angular 2. I wrote this answer assuming you are using Angular 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.