I want to implement a like button (like in instagram, twitter etc) in my nativescript angular 2 app. clicking on the label should add the "active" class to the label. After clicking it again, it should remove the "active" class.
home.component.html
<label text="{{ post.likes }}" class="" (tap)="like()">
home.component.html (after clicking the label)
<label text="{{ post.likes }}" class="active" (tap)="like()>
home.component.ts
like() {
if (/* post contains "active" class */) {
// remove "active" class to label
} else {
// add "active" class to label
}
}
Labelwith uppercaseL- Narendra