1

i have 2 set of arrays, one in Group and the other List Not in group. I have 2 buttons, move to right and move to left, so on click of them, the selected data must move to right or to left based on button we select. Here multiple selection of data in list should also be implemented. I have used jQuery but it didnt worked with array of data binded, and the selected list also didnt get active in the class, in html, and here multiple list selection is not happening, one at a time is working

Without using jquery how can this be implemented.

DEMO: DEMO

HTML:

 <li class="list-group-item" *ngFor="let item of agentInView; let i=index" (click)="select(i)" [ngClass]="{'active': selectedIndex == i, 'list-group-item': true}">{{item.value}}</li>

Ts:

   selectInView(index: number) {
      this.selectedinViewIndex = index;
  }
5
  • Just remove the element from one array and push it to another. Commented Jan 16, 2020 at 11:15
  • is it possible to remove multiple and multiple at a time? Commented Jan 16, 2020 at 11:22
  • 1
    You should not mix javascript with jquery, thats a bad practice. If using jQuery, then why using angular. Commented Jan 16, 2020 at 11:29
  • I dont want to use jquery, i used javascript itself, i am working on demo, will delete jquery file Commented Jan 16, 2020 at 11:30
  • @qiAlex any idea about the question i asked for? Commented Feb 24, 2020 at 11:59

1 Answer 1

3

There is a demo with multiple selections and moving from one list to another.

  • Selections are getting clear after moving,
  • Sort is always by id

https://stackblitz.com/edit/angular-lh5vzl?file=src%2Fapp%2Fapp.component.ts

Sign up to request clarification or add additional context in comments.

6 Comments

Thats a nice demo :)
I used to use ngClass always, but from this i learnt without using ngClass also we can add class on condition
I would better prefer to avoid using ngClass because of it's performance. I have a different topic about it here stackoverflow.com/questions/46605252/…
Thanks a lot, really it was informative and it motivates me to learn more, keep up the research work, thanks man :-)
@qiAlex could you please help me to solve this question , stackoverflow.com/questions/60360555/…
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.