Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox should support null/undefined model #2864

Closed
sheppard30 opened this issue May 24, 2017 · 5 comments
Closed

Checkbox should support null/undefined model #2864

sheppard30 opened this issue May 24, 2017 · 5 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@sheppard30
Copy link

I'm submitting a ...

[ x  ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
http://plnkr.co/edit/PPIk2sjGNI9EyGhdkA9e?p=preview

Current behavior
I want to create a simple checkbox with my own event handler - just run method when checkbox is clicked but it generates error:

Checkbox.html:7 ERROR TypeError: Cannot read property 'concat' of undefined
at Checkbox.addValue (checkbox.ts:106)
at Checkbox.updateModel (checkbox.ts:76)
at Checkbox.onClick (checkbox.ts:66)
at Object.eval [as handleEvent] (Checkbox.html:7)
at handleEvent (view.ts:140)
at callWithDebugContext (services.ts:645)
at Object.debugHandleEvent [as handleEvent] (services.ts:241)
at dispatchEvent (util.ts:173)
at eval (element.ts:221)
at HTMLDivElement.eval (dom_renderer.ts:75)
at ZoneDelegate.invokeTask (zone.js@0.8.4?main=browser:398)
at Object.onInvokeTask (ng_zone.ts:253)
at ZoneDelegate.invokeTask (zone.js@0.8.4?main=browser:397)
at Zone.runTask (zone.js@0.8.4?main=browser:165)
at HTMLDivElement.ZoneTask.invoke (zone.js@0.8.4?main=browser:460)

Expected behavior
It should not fail.

Minimal reproduction of the problem with instructions
Click on checkbox and watch console log

Please tell us about your environment:
Windows 7

  • Angular version: 2.0.X
    4.0.0

  • PrimeNG version: 2.0.X
    4.0.1

  • Browser:
    Chrome

@sudheerj
Copy link
Contributor

sudheerj commented May 24, 2017

This is because you didn't define model or value for default multi checkbox behavior
So either you should set binary=true or define model
#2870

@sheppard30
Copy link
Author

@sudheerj with attribute "value" the issue persists. I do not need ngModel for this because I am going to use onChange(). ngModel should be optional in this case.

@sudheerj
Copy link
Contributor

Yeah, it won't depend on value setting. The PR will give clear distinction between single and multi checkbox

@cagataycivici cagataycivici changed the title Checkbox onChange method generates error Checkbox should support null/undefined model May 25, 2017
@cagataycivici cagataycivici self-assigned this May 25, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label May 25, 2017
@cagataycivici cagataycivici added this to the 4.0.2 milestone May 25, 2017
@codedumper
Copy link

codedumper commented May 26, 2017

Will it solve the same issue in ReactiveForm ?
<p-checkbox formControlName="is_911_passthrough"></p-checkbox>
generate the same error (formControl is existing).

@cagataycivici
Copy link
Member

I believe so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

4 participants