matsura / ng2-dual-list-box

A dual list box component for Angular 4
http://ng2-duallistbox-demo.surge.sh/
28 stars 20 forks source link

Question Clearing selected Items #18

Open alu-ac opened 6 years ago

alu-ac commented 6 years ago

This might be a silly question. I fairly new to this.

I'm trying to clear the selected items. I'm using [(ngModel)]=selected. If I modify selected to be empty, the items remain on the right box.

What do I need to do to clear the right box. Or to fully refresh the component?

deiyanfott commented 6 years ago

@alejandrot3

My teammate and I found a workaround for this issue.

In the component tag <ng2-dual-list-box ...>, you can do something like <ng2-dual-list-box #test ...>.

Then plug it in some method you are using, say (click)=finishTask(test, ...)

Then inside the method you can do finishTask(test: DualListBoxComponent, ...) { test.selectedItems = []; }

Hope this helps if you still haven't found a solution.

@matsura

Is there a better way to do this without passing the component?

noumanbhatti commented 5 years ago

Did anybody find a better way of doing this?

Or is there a better control available to use with Angular 6?

jayadn21 commented 3 years ago

@deiyanfott your solution is working fine, thanks for ur help.