0

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.

1
  • You have a typo in your template, you wrote locknumber instead of locknumbers. Commented Sep 10, 2021 at 12:12

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

why don't you use this code better for the toggle button

this.locknumbers = true;
onclick(){
this.locknumbers = !this.locknumbers
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.