Reputation: 21
My code:
component class:
this.locknumbers = true;
onclick(){
this.locknumbers = false;
}
.disabledRows {
opacity: 0.5;
filter: alpha(opacity=50);
cursor: default;
}
[ngClass]= "{'disableRows':locknumber}".
<a (click)="onClick()"> Enable </a>
Initially it is disabled but when I click on enabled button, the contents are still disabled but in console I can see the value of this. lock numbers changing to false; even though the style class is applied on click.
Upvotes: 0
Views: 453
Reputation: 802
why don't you use this code better for the toggle button
this.locknumbers = true;
onclick(){
this.locknumbers = !this.locknumbers
}
Upvotes: 0
Reputation: 85
There is typo also in css class name disableRows
and disabledRows
.
If you are using VSCode, checkout extension "Angular Language Service". It can detect variable names in angular components. It doesn't help in the CSS class name part, but it will catch the locknumber
variable name and type in the template.
Your code should be fine after typos fixed.
Upvotes: 1