dynamic disabled property not working with formcontrol

UI Components for Angular
Post Reply
sspnet
Posts: 3
Joined: 25 Nov 2020, 11:18

13 Jan 2022, 21:47

I am using v13.04 of primeng and I am trying to set the inputText input disabled dynamicly. This does not work?
<input
[type]="question.type"
pInputText
[id]="question.key"
[name]="question.key"
[disabled]="question.prop?.disabled"
[formControlName]="question.key"
>

I tried many options (hardcode the value to true, disabled etc. but nothing works.

When I remove the brackets the fields are disabled
<input
[type]="question.type"
pInputText
[id]="question.key"
[name]="question.key"
disabled="true"
[formControlName]="question.key"
>

Is this not supported with formControl?

This is the result in runtime:
<input _ngcontent-kim-c152="" pinputtext="" class="p-inputtext p-component p-element ng-untouched ng-pristine ng-valid" type="text" id="doorkies" name="doorkies" ng-reflect-is-disabled="true" ng-reflect-name="doorkies">

monikm
Posts: 2
Joined: 22 May 2023, 11:34

22 May 2023, 11:40

Hi, I am having the same issue. It was working fine until I updated primeng/Angular

"primeflex": "^3.3.0",
"primeicons": "^6.0.1",
"primeng": "16.0.0-rc.1",

This doesn't show disabled anymore when set to "true":

<p-selectButton [options]="yesNoOptions"
[disabled]="viewMode"
formControlName="isInterestBearing">
</p-selectButton>

Any news on this?

monikm
Posts: 2
Joined: 22 May 2023, 11:34

22 May 2023, 12:08

I got it working again.

this is my control:

<p-selectButton [options]="yesNoOptions"
[disabled]="viewMode"
formControlName="isInterestBearing">

This is how I set it:

var accountDetailsValidation: FormGroup = new FormGroup({
isInterestBearing: new FormControl({value: bankAccount.isInterestBearing,disabled: this.isDisabled }, [Validators.required])
});

And this is the isDisabled

get isDisabled():boolean{
return this.viewMode;
}

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests