Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Checkbox Input bind not working properly #1911

Closed
raftalks opened this issue Jan 29, 2013 · 3 comments
Closed

Checkbox Input bind not working properly #1911

raftalks opened this issue Jan 29, 2013 · 3 comments

Comments

@raftalks
Copy link

Hi,

I am using a checkbox bind to json object where the value is numeric 1 or 0. Angularjs doesn't seem to work properly if the value of the model is numeric.

See this plunkr below and note that "value2" model obj given numeric value 1 and having the checkbox field with ng-true-value='1' doesn't make the checkbox checked.

With observation, I have noticed angular ng-true-value is actually doing '1' === 1 to model numeric value and returns false, this can work if it compares with == only. This is define in the line here I think: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L646

Plunkr: http://plnkr.co/edit/cBBj54NKQ0OZXSZCQkdd?p=preview

raftalks added a commit to raftalks/angular.js that referenced this issue Jan 29, 2013
Here is the solution to issue angular#1911
@raftalks raftalks mentioned this issue Jan 29, 2013
@latentflip
Copy link
Contributor

Seems like a useful issue to fix, not sure if using "==" will raise issues elsewhere though?

@latentflip
Copy link
Contributor

This is actually a dupe of #1199, so we can probably close this discussion and move it over there.

@pkozlowski-opensource
Copy link
Member

Duplicate of #1199

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

3 participants