So I have an *ngFor list of songs. I would like for the user to click on a thumb, and then for that thumb to be higlighted, then set a propety whether the song is thumbs up, or thumbs down based off that click event. I would like for the thumb to turn blue when the clicked property is true.
This is what it looks like:
TypeScript:
thumbsVisible: boolean = false;
thumb: string = ""
click(song){
console.log("Thumb is: " + song.thumb)
}
HTML:
<ul> <!-- Each song on the album -->
<li class="song-block"
*ngFor='let song of songsToDisplay'
(click)="getSong(song)"
(mouseenter)="song.thumbsVisible=true"
(mouseleave)="song.thumbsVisible=false">
<div class="song-card"
(click)="addPlay(song)">
<p *ngIf="!song.isPlaying"
class="song-number">{{song.tracknumber}}</p>
<i *ngIf="song.isPlaying" class="fa fa-play"></i>
<p class="song-name">{{song.name}}</p>
<p class="song-length">{{song.length}}</p>
<div class="thumbs"
*ngIf="song.thumbsVisible"> <!-- Thumbs section -->
<i class="fa fa-thumbs-up fa-lg"
(click)="song.thumb='up'"
(click)="click(song)"></i>
<i class="fa fa-thumbs-down fa-lg"
(click)="song.thumb='down'"
(click)="click(song)"></i>
</div> ...
</ul>