lundi 22 mai 2017

Angular2 bind value of map to checkbox

I'm trying to bind the value of a map to html checkbox in angular2.

    this.profilType = new Map<string, boolean>();
    this.profilType.set("public", true);

to

    <input type="checkbox" [(ngModel)]="profilType['public']"/>

I tried this before, but it caused errors.

    <input type="checkbox" [(ngModel)]="profilType.get('public')"/>

Currently, no errors are displayed but it seems that there's no binding neither.

I found some solutions by using (click) mechanism but this are not relevant. Checkbox really need to react to component change.

Is there a way to do that or should I use different approach (advices are welcome too).

Thanks




Aucun commentaire:

Enregistrer un commentaire