Reputation: 313
I don't know where I'm getting wrong.
app.component.html
<div [ngClass]="stylemethodName();"> ngClass with method </div>
app.component.ts
export class AppComponent {
title = 'Simple_CRM_App';
stylemethodName(){
return 'c3';
}
}
app.component.scss
.c3 {
color:red;
}
I'm getting an error in the template app component.
Upvotes: 0
Views: 354
Reputation: 20354
Remove the ;
from the expression:
<div [ngClass]="stylemethodName()"> ngClass with method </div>
Also, it is really bad practice when you are returning values from the function. That function will be triggered on each Change Detection. Try to implement a logic in template directly.
Upvotes: 1