0

I am using angular 4 for page design. The checkbox is not getting selected no matter what value I pass, below is my code for same -

<div class="form-check">
    <label class="form-check-label">
      <input type="checkbox" value="false"> No
    </label>
</div>

I have tried with value="true", value=true, checked="true", checked=true. My intention is to use an expression or a dynamic value to set check box selection. Any help would be greatly appreciated.

4
  • [checked]="true" you want this? Commented Nov 23, 2017 at 11:37
  • 1
    ngModelues [ngModel]="true" Commented Nov 23, 2017 at 11:38
  • @Aravind Yup that works, thanks for the help, if you put that in answer I will accept it. Commented Nov 23, 2017 at 11:40
  • @Jeet Done. (y) Commented Nov 23, 2017 at 11:47

1 Answer 1

3

As per comment,

Use ngModel

<div class="form-check">
    <label class="form-check-label">
       <input type="checkbox" [ngModel]="false"> No
    </label>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Why the same way it doesn't work for reactive forms if we use formControlName?

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.