techie_questie
techie_questie

Reputation: 1522

Radio button is not getting checked on page load by default in Angular2

I have a form which has two radio buttons say Yes and No. I need to select No on page load or by default we can say.

In my HTML-

<md-radio-group>
 <md-radio-input #rdoYes [value]="true">Yes</md-radio-input>
 <md-radio-input #rdoNo [value]="false"[checked]="rdoNo===false">No</md-radio-input>
</md-radio-group>

I am doing something like this but the "No" radio button is not getting selected by default.

Upvotes: 1

Views: 2462

Answers (1)

Mozgor
Mozgor

Reputation: 204

If you want to set a fixed value, then you should get ride off those [], like value="true".

About the selection in itself, you should probably do [checked]="rdoNo.value === false".

Please let me know in comment if you get any progress and I'll be pleased to help you to end the problem.

Upvotes: 1

Related Questions