I want to move the icon that I added to the screen smoothly with Angular.

Asked 2 years ago, Updated 2 years ago, 90 views

Angular has the following HTML and components:
The IconInfo class has an icon and icon name.

When the button is pressed from the screen, addIconInfo is called and
Each time a button is pressed, an icon is added to the screen.

Therefore,
in the area where icons are displayed when icons are added
From the bottom to the top (as if it were accumulating on top) I'd like to, but is there any way?
Would it be difficult to do it with ngFor alone?

◆ HTML

<div class="page">
  <section class="card">
  <ng-container*ngFor="letion of icons">
   <div class="media">
     <img src={icon.img}}>
   </div>
  </ng-container>
  </section>
</div>

◆ Components.ts

addIconInfo(icon:string, name:string){
     This.icons.push (new IconInfo(icon, name));
  }

angular4

2022-09-30 19:44

1 Answers

I don't know what this.icons looks like, but if it's simply Array, it's not push to add it to the end, but unshift to add it to the beginning.

this.icons.unshift (new IconInfo(icon, name));


2022-09-30 19:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.