Currently tackling an angular project and seeking assistance with a particular issue...
I have successfully displayed data from an array, but now I am looking to store the value of the element I click on so that I can utilize it in another component along with an API link
Here is the code snippet for the component responsible for displaying the data
<div class="popup-content">
<ul class="list-group">
<li mat-dialog-close
routerLink='/admin'
*ngFor="let t of data"
class="list-group-item">
{{t}}
</li>
</ul>
</div>
How can I capture and save the value of 't' upon clicking, so that it can be accessed in another component?
The data array initialization looks like this
this.service.getPosts()
.subscribe(response => {
this.posts = response;
this.num = this.posts.body.paginationinfo.numberofelementsTotal;
for(this.i=0;this.i<this.num;this.i++)
{
this.test.push(this.posts.body.listOfUnapprovedChangeRequests[this.i].requestuuid);
}
});
console.log(this.test);
}
openDialog(){
this.dialogRef.open(MenupopupComponent,{data:this.test})
}