I get ERROR TypeError: _co.onClick is not a function error with angular 2.
<span
class="glyphicon"
[class.glyphicon-star]="isFavorite"
[class.glyphicon-star-empty]="!isFavorite"
(click)="onClick()">
</span>
When user click the star that it should be color or empty. then my component ts file is here
@Component({
selector: 'favorite',
templateUrl: './favorite.component.html',
styleUrls: ['./favorite.component.css']
})
You need to declare that onClick function in your component.
@Component({
selector: 'favorite',
templateUrl: './favorite.component.html',
styleUrls: ['./favorite.component.css']
})
export class FavoriteComponent {
constructor() { }
onClick() {
console.log("star clicked");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With