Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

bug(md-checkbox): ngChecked directive not working #535

Closed
brettstack opened this issue Nov 4, 2014 · 13 comments
Closed

bug(md-checkbox): ngChecked directive not working #535

brettstack opened this issue Nov 4, 2014 · 13 comments
Assignees
Milestone

Comments

@brettstack
Copy link
Contributor

According to the doc:

The checkbox directive is used like the normal angular checkbox.

But I am unable to get ngChecked working.

@vergun
Copy link

vergun commented Nov 4, 2014

You need to have an ng-model attribute alongside the ng-checked attribute

On Tue, Nov 4, 2014 at 12:30 AM, breandr notifications@github.com wrote:

According to the doc:

The checkbox directive is used like the normal angular checkbox.

But I am unable to get ngChecked working.


Reply to this email directly or view it on GitHub
#535.

@brettstack
Copy link
Contributor Author

It works on a standard checkbox fine without an ng-model though.

@vergun
Copy link

vergun commented Nov 5, 2014

You're going to need to provide more detail to troubleshoot this issue.
Based on the feedback I'm not sure what you mean by it works on a standard
fine. A plunker or fiddle is not necessary but would go a long way to help
troubleshoot and resolve.

On Tue, Nov 4, 2014 at 10:18 PM, breandr notifications@github.com wrote:

It works on a standard fine without an ng-model though.


Reply to this email directly or view it on GitHub
#535 (comment).

@brettstack
Copy link
Contributor Author

It was supposed to read "standard checkbox" but I put the html element, so it just skipped it. I edited but you mustn't have received an email with the update. http://plnkr.co/edit/KldWCcKJXqQxIKwFQeki?p=preview

@vergun
Copy link

vergun commented Nov 6, 2014

​The problem is you're not using ng-model, if you want the checkbox to
default to checked, have the value of the ng-model be truthy and it will be
checked.

Here's a plunker based off yours
http://plnkr.co/edit/RKwM5mRYLh5k6MoAyLnS?p=preview

On Wed, Nov 5, 2014 at 1:22 PM, breandr notifications@github.com wrote:

It was supposed to read "standard checkbox" but I put the html element, so
it just skipped it. I edited but you mustn't have received an email with
the update. http://plnkr.co/edit/KldWCcKJXqQxIKwFQeki?p=preview


Reply to this email directly or view it on GitHub
#535 (comment).

@brettstack
Copy link
Contributor Author

Right, but my point is that ng-checked works for standard checkboxes but not md-checkbox. If you look at my original plunkr you will see the standard checkbox does not use ng-model but is still checked because ng-checked is truthy. My use case is I have a checklist directive, and the first checkbox in the checklist is a special "All" checkbox. Checking this unchecks all checked checkboxes, and by checking one again I want the "All" checkbox to be unchecked.

<md-checkbox ng-click="dropdownChecklistCtrl.selected = []", ng-checked="dropdownChecklistCtrl.selected.length === 0">All</md-checkbox>

Sure, I can make this work by using ng-model, but I'd rather not. And since it works with a standard checkbox, this is either a bug with md-checkbox or a documentation issue.

@vergun
Copy link

vergun commented Nov 6, 2014

md-checkbox doesn't support checked. If you feel it's necessary you can
submit a pull request that updates the directive scope to accept
ng-checked/checked as an attribute and pass that value when present onto
the input within the directive template.

On Wed, Nov 5, 2014 at 9:32 PM, breandr notifications@github.com wrote:

Right, but my point is that ng-checked works for standard checkboxes but
not md-checkbox. If you look at my original plunkr you will see the
standard checkbox does not use ng-model but is still checked because
ng-checked is truthy. My use case is I have a checklist directive, and the
first checkbox in the checklist is a special "All" checkbox. Checking this
unchecks all checked checkboxes, and by checking one again I want the "All"
checkbox to be unchecked.

<md-checkbox ng-click="dropdownChecklistCtrl.selected = []",
ng-checked="dropdownChecklistCtrl.selected.length === 0">All

Sure, I can make this work by using ng-model, but I'd rather not. And
since it works with a standard checkbox, this is either a bug with
md-checkbox or a documentation issue.


Reply to this email directly or view it on GitHub
#535 (comment).

@ThomasBurleson ThomasBurleson added this to the 0.7.0-rc1 milestone Nov 14, 2014
@yesnault
Copy link

👍

@sudeshnaDatta
Copy link

How to use md-checkbox to select an entire row when used inside a grid

@Elfayer
Copy link

Elfayer commented Dec 2, 2015

+1, This is a real big issue. It's a regression from angularJS.

@DarkMerge
Copy link

+1

1 similar comment
@kamikaze942
Copy link

+1

@ThomasBurleson
Copy link
Contributor

@Elfayer - are you saying that this issue has not been fixed with the latest codebase in master? If that is the case, please submit a new issue with a codepen demo. thank you.

@angular angular locked and limited conversation to collaborators Jul 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants