Thursday, July 13, 2017

Clippy lives!

When I attempt to put [disabled]="whatever" inline at an input tag in an Angular 2 rective form and then run my application not only does the trick not work, but this makes its way up to the console to boot:

It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this approach to avoid 'changed after checked' errors.
 
Example:
form = new FormGroup({
   first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
   last: new FormControl('Drew', Validators.required)
});

 
 

That said, I tried to do things Clippy's looks-like-you're-trying-to way and it didn't work either. At the moment I am just dealing with the problem like this:

<ng-container *ngIf="!whatever">
   <input type="text" formControlName="Foo">
</ng-container>
<ng-container *ngIf="whatever">
   {{stuff.Foo}}
</ng-container>

No comments:

Post a Comment