I have a use case where a component form shared between Admin and Employee. When the component is access by Admin, the form is write-able but READONLY when access by employee. i know the simplest code line to make the form READONLY when access by employee is
Controller Logic
createEntitlementForm() {
this.entitlementForm = this.formBuilder.group({
entitlements: this.formBuilder.array([])
});
}
async populateEntitlementForm() {
this.user = await this.alicia.getUser(this.email);
this.claimTypes = await this.alicia.getClientDoc("Claim/ClaimTypes");
this.entItems = await this.hcm.CLMGetEntitlements(3, this.email);
Object.keys(this.entItems).forEach(k => {
this.addEntitlement({ docId: k, ...this.entItems[k] });
});
if (!this.bAdminAccess) {
this.entitlementForm.disable({ onlySelf: false });
}
}
But it will make the form extremely hard to read as all text become grey. Is there a way to keep the form READONLY but still keep the text as black color to improve readability? I know i can use [readonly]=1 in template file but it seems is not the recommended way as chrome alerted me to disable under control layer and not template layer.
I do not share the template logic as it's too long and i disable via controller and not template. Here is my newly built sample https://stackblitz.com/edit/ng-disableform