angular2-multiselect-dropdown
angular2-multiselect-dropdown copied to clipboard
selectedItems still selected after clearing them via [x] Button
When I selected some items and want to deselect them with the DeselectAll-Button [x], they get removed from the UI but they're still selected in the array. The only way to clear them correctly is, to deselect them one by one. Unfortunately the DeselectAll-Button can't be removed by the settings.
I have replicated the issue at https://stackblitz.com/edit/angular-yatsa4?file=src%2Fapp%2Fapp.component.html
My current workaround is to use the 'onDeSelectAll'-Event and clear the selectedItems manually by initializing a new array.
This button DeselectAll-Button [x] calls onDeSelectAll() method
public onDeSelectAll(items: any) {
console.log(items)
}
In this method items will be empty [] so you can use this for update your array of selected items But this.selectedItems still with previous data but it is not problem for you
ps: I think it's not a bug, it wasn't problem to me
just to clarify
public onDeSelectAll(items: any) {
console.log(items)
}
in this example, the parameter items will always be empty/undefined, isn't it? So why use it at all? I can't imagine it's on purpose, that you have to manually update the array after the given DeselectAll-Button [x] gets clicked.
It's not a big problem, because a workaround exists. Just wanted to mention, that this behavious exists and I'm not sure if it's supposed to work like this. :-)