Skip to content

Set default state of a checkbox #405

Closed
@chriscurnow

Description

@chriscurnow

This seems like a really stupid question but I just can't find the answer anywhere.

I want to set the initial state of a checkbox based the initial state of the data object.

Eg the data object may have an attribute "isAvailable" so I want to set the checkbox to match the value of isAvailable.

The problem I am having is that to set the initial state of a check box to checked you add the "checked" attribute to the form control.

(This seems silly as it would seem better to have used checked="true" as you can read the value of the checkbox by reading its "checked" value. Anyway that's not the way it is.)

So it looks like I would have to do an NgIf.

I'm sure there must be an easier way but I just can't find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions