Hi, I’m trying to enable and disable components using [disabled]=”condition” in template. This works fine when condition is toggled true, but it doesn’t work when changed to false.
example template html
<jqxButton [disabled]='!enabled'>My button</jqxButton>
<jqxButton (onClick)="toggle()" >Toggle</jqxButton>
My button should be enabled: {{ enabled }}
example ts
import { Component, OnInit } from '@angular/core';
import { jqxButtonComponent } from "../../libs/jqwidgets-ts/angular_jqxbuttons"
@Component({
selector: 'example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit {
constructor() { }
enabled : boolean = true;
ngOnInit() {
}
toggle() : void {
this.enabled = !this.enabled;
}
}
In the examle “My button” is enabled, then it becomes disabled when I press “toggle”. If I press “toggle” again I espect “My button” to be enabled again but it keep be disabled. What am I doing wrong?