NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.86k stars 3.91k forks source link

[disabled]="true" on Input does not work if it contains a formControlName #6990

Closed JesusSilva closed 2 years ago

JesusSilva commented 2 years ago

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-ivy-5mgejm?file=src/app/app.component.ts

Steps to reproduce

Add the formControlName property to a field with [disabled]="true".

What is expected?

The input is expected to be disabled when the disabled is set to true.

What is actually happening?

Currently not disabled

Environment Info
ng-zorro-antd 12.0.1
Browser Chrome
ruthyankson commented 2 years ago

Make it disabled=true, instead. Simply remove the brackets and it works.

xylplm commented 2 years ago

我也遇到了相同的问题,希望尽快修复!

vthinkxie commented 2 years ago

plz check the angular form best practice, you can not use both ReactiveForm and TemplateForm in the same component.

xylplm commented 2 years ago

plz check the angular form best practice, you can not use both ReactiveForm and TemplateForm in the same component.

我的组件中一样出现了这个问题,并没有使用模板驱动。用的响应式表单来实现的。[disabled]="true"这个属性是input元素本身的属性,也并不是模板驱动独有。angular官方也是支持这样用的

vthinkxie commented 2 years ago

https://stackoverflow.com/questions/42840136/disable-input-fields-in-reactive-form