I am new to Angular and I am having trouble making my right-click delete function show the delete button one at a time as opposed to all at once in the right-clicked menu. This is my array of strings account:string[] = ["one", "two", "three"]; This is where I performed the right-clicked function {{ listitem }} My Right Clicked Function @ViewChild('menu') menu!: ElementRef;rightMenu(e: MouseEvent) { e.preventDefault(); this.menu.nativeElement.style.display = "block"; this.menu.nativeElement.style.top = e.pageY + "px"; this.menu.nativeElement.style.left = e.pageX + "px"; This is where I did delete Delete And this is my delete function delete(index: number) { this.account.splice(index, 1); How do I make my right-click menu show one delete at a time as opposed to showing every delete button in the menu at once?
I am new to Angular and I am having trouble making my right-click delete function show the delete button one at a time as opposed to all at once in the right-clicked menu.
This is my array of strings
account:string[] = ["one", "two", "three"];
This is where I performed the right-clicked function
<div (contextmenu) = "rightMenu($event)" (click) = "disappearContext()"> {{ listitem }} </div>
My Right Clicked Function
@ViewChild('menu') menu!: ElementRef;rightMenu(e: MouseEvent) { e.preventDefault(); this.menu.nativeElement.style.display = "block"; this.menu.nativeElement.style.top = e.pageY + "px"; this.menu.nativeElement.style.left = e.pageX + "px";
This is where I did delete
<div class= "customContext" #menu> <ul> <div *ngFor = "let listitem of account; let myIndex=index;"><li (click) = "delete(myIndex)">Delete</li></div> </ul> </div>
And this is my delete function
delete(index: number) { this.account.splice(index, 1);
How do I make my right-click menu show one delete at a time as opposed to showing every delete button in the menu at once?
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images