Primeng: Checkbox / Reactive Form / Multiple Value

Created on 23 Aug 2017  路  4Comments  路  Source: primefaces/primeng

[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

Hello,

I have have this :

        <p-checkbox *ngFor="let option of attr.options" [formControlName]="field.key"
                    [value]="option.value"
                    [label]="option.label"
                    (onChange)="change($event)">
        </p-checkbox>

And if I select a second value, this one erase the first value selected in my formControl.

In primeNG checkbox component, this code is called:

    addValue() {
        if(this.model)
            this.model = [...this.model, this.value];
        else
            this.model = [this.value];
    }

"this.model" is never set and I pass alway in the else condition.

Any idea ? Bugs ?

Thx

  • Angular version: 4.3.X
  • PrimeNG version: 4.1.X

Most helpful comment

Duplicate from mine ?

All 4 comments

I got the same issue, when selecting multiple values only the last selected one gets selected. Deselecting works the same as selecting, last one gets deselected while the first deselected gets selected again.

Hi, this seems like a duplicate of #2906, I've just posted a solution there, hope it helps.

Duplicate of #3734

Duplicate from mine ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

just-paja picture just-paja  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

Helayxa picture Helayxa  路  3Comments

mitosandov picture mitosandov  路  3Comments

philly-vanilly picture philly-vanilly  路  3Comments