Hi, is there a way to clear selection inside a function?, for example i need to clear my selection after a variable changes.
any update?
2
any update on this? I am desperately trying to do this but I have no luck
Hi,
found a solution using "component interaction":
--these go on the top
import {ViewChild } from "@angular/core";
import {SelectComponent } from 'ng2-select/ng2-select';
--these goes in your export class component
--myDivId is used like this
@ViewChild('myDivId')
private mySelectList: SelectComponent;
then in your function you call it like this:
if (this.mySelectList) {
var activeItem = this.mySelectList.activeOption;
if (activeItem) {
this.mySelectList.remove(activeItem)
}
}
this will remove the selection if youre using ng2-select in single mode. you can modify this to remove multiple items if youre using it in multiple mode.
I hope it helps.
@valorkin ,i will love to submit a PR today to take care of selectAll and unselectAll.Can I proceed?
Sure, I will be grateful :)
I will be sending it soon in the next 24hours max
@valorkin sent about 5hrs ago,kindly review the PR #648
in terms of unselectAll, select All, there is a cleaner solution that doesn't use @ViewChild,
in your typescript,
private yourVariableName: any=[ ];
private clearDropDown( ){
this.yourVariableName = [ ];
}
This works with ng2-select-compact also.
Most helpful comment
in terms of unselectAll, select All, there is a cleaner solution that doesn't use @ViewChild,
in your typescript,
private yourVariableName: any=[ ];
private clearDropDown( ){
this.yourVariableName = [ ];
}
This works with ng2-select-compact also.