Reputation: 1815
I'm using https://github.com/Gbuomprisco/ngx-chips with two input fields. If a tag gets removed from the first input ("likes") it gets added to the second input ("dislikes).
This doesn't work if there is some input in the second field first.
TS:
public likes = [];
public dislikes = [];
onLikeRemove(tag) {
this.dislikes.push(tag);
console.log(this.dislikes);
}
HTML:
<tag-input [ngModel]="likes" (onRemove)="onLikeRemove($event)">
</tag-input>
<tag-input [ngModel]="dislikes">
</tag-input>
Steps to reproduce:
1) Add a tag to "dislikes"
2) Add a tag to "likes"
3) Remove the tag from likes - it should be added to dislikes, but that doesn't work.
Is this a bug in the library or am I getting something more basic wrong?
Upvotes: 0
Views: 3014
Reputation: 3574
Use two way binding in your code to reflect the changes on UI:
<tag-input [(ngModel)]="likes" (onRemove)="onLikeRemove($event)">
</tag-input>
<tag-input [(ngModel)]="dislikes">
</tag-input>
Upvotes: 2