I have an Angular form.
<form class="p-16" name="poMaterialDetailForm [formGroup]="poMaterialDetailForm">
Inside the form I have a save button.
<button mat-raised-button
class="save-poMaterialDetail-button ml-32 mr-8"
[disabled]="poMaterialDetailForm.invalid || poMaterialDetailForm.pristine"
<span>SAVE</span>
</button>
The disabled attribute allows me to disable the button when there are no changes in the form. If form values are changed then save button becomes active.
I just added a user permission feature and save button is also disabled for users who does not have editing access.
<button mat-raised-button
class="save-clientManagementDetail-button ml-32 mr-8"
[disabled]="isDisabled('ClientManagement','Edit')"
*ngIf="pageType ==='edit'" (click)="saveClientManagementDetail()">
<span>SAVE</span>
</button>
Now I want to use both features for disabled attribute. Here is my condition:
[disabled]="(clientManagementDetailForm.invalid || clientManagementDetailForm.pristine)
&& isDisabled('ClientManagement','Edit')"
Unfortunately I cannot make this conditions to work. When I use the conditions seperately they work but when I try to use them at the same time, disabled attribute does not change properly accordingly.
Hope the conditions are clear. I would appreciate if anyone can shed some light on this subject.
Cheers, Johnny