question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-checkbox don't honor the [value] binding

See original GitHub issue

Bug, feature request, or proposal:

md-checkbox don’t honor the [value] binding.

What is the expected behavior?

https://material.angular.io/components/component/checkbox mentions an @Input value property that can be set as the value for this input.

What is the current behavior?

It only uses boolean values, it does not use whatever the user specifies in [value].

What are the steps to reproduce?

http://plnkr.co/edit/4ryXsamVJlcMaDHJsEgu?p=preview

Providing a Plunker (or similar) is the best way to get the team to see your issue. Plunker template: https://goo.gl/DlHd6U

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

When trying to implement a checkbox-list control I want to have an array with the values that are represented by the checkboxes.

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

Angular material: 2.0.0-beta.6 Angular: 4.1.1

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
masterflodacommented, Dec 8, 2017

I think this is a bug, not a feature. if you submit a HTML form with <input type="checkbox" name="foo" value="bar"> the parameter foo will have the str value bar, not bool true.

1reaction
julianobrasilcommented, Jun 7, 2017

Maybe the confusion (or frustration) comes from the fact that the component has two different conteptual things that look similar at a first glance: it’s state (true/false) and it’s value. The state is what’s (correctly) passed to ngModel.

But this aproach is not so useful when you have a list of checkboxes to check (in this case, @macjohnny 's example plunker is a good way to handle it).

Take a look at this issue: #4926. Someone is asking for implementation of a MdCheckboxGroup feature. If it gets implemented, it’ll possibly work like MdRadioGroup, binding the value property of the selected checkboxes to ngModel of the MdCheckboxGroup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checkbox not binding to scope in angularjs - Stack Overflow
The best practice is to never bind directly to a variable on the scope in an ng-model , this is also known as...
Read more >
Directives > mdCheckbox - AngularJS Material
Assignable angular expression to data-bind to. ... If a truthy expression or no value is passed in the checkbox renders in the md-indeterminate...
Read more >
Falcon Sandbox v8.30 © Hybrid Analysis
Submit malware for free analysis with Falcon Sandbox and Hybrid Analysis technology. Hybrid Analysis develops and licenses analysis tools to fight malware.
Read more >
Untitled
M1 southbound roadworks, Gamestop 60458, Barcelona wash basin, Price of ek mukhi rudraksha ... Future looking for her, Md-checkbox value, Ragtime 2016 tour!...
Read more >
Selection Controls - KivyMD's documentation - Read the Docs
MDCheckbox : on_active: app.on_checkbox_active(*args). def on_checkbox_active(self, checkbox, value): if value: print('The checkbox', checkbox, 'is active', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found