Skip to content

When MdCheckbox is initialized to true, the internal native checkbox has checked == false #2001

@pvamshi

Description

@pvamshi

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When the modal value is true, the input we hide should also have the value of true . It gets true when we uncheck and check the checkbox manually.

What is the current behavior?

input element default value is false

What are the steps to reproduce?

https://plnkr.co/edit/SS6LBPL3ucXx1njTRGkF?p=preview

Inspect the checkbox and run this in the console :
$0.querySelector('input').checked // assuming chrome dev environment

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, browsers are affected?

Angular : 2.2.1
Material: ^ 2.0.0-alpha.10

Is there anything else we should know?

This was a deal breaker while testing the code.
There is another issue , not sure worth creating another bug :
When testing the component using jasmine, the only way to check the checkbox is checked is to look for the class 'md-checkbox-checked' is present. Even this class is not present while testing so there is no way to test if the checkbox is checked when model value is true while rendering.

I could not get the spec working in plnkr, so created a project with the unit tests :
https://github.com/pvamshi/md-checkbox-test

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaround

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions