NG-ZORRO / ng-zorro-antd

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

模板驱动表单中使用nz-cascader时设置ngModel默认值无法正确回显选中 #6855

Closed mrlionline closed 3 years ago

mrlionline commented 3 years ago

Reproduction link

https://stackblitz.com/edit/angular-w6gvrh?file=src/app/app.component.ts

Steps to reproduce

  1. 新建模板驱动表单
  2. 在nz-form-control增加nz-cascader,并设置ngModel
  3. 查看选中状态(未选中ngModel设置的value)
  4. 在form外写同样的nz-cascader可以选中

What is expected?

模板驱动表单中正确回显级联字段

What is actually happening?

模板驱动表单中未正确回显级联字段

Environment Info
ng-zorro-antd 11.4.1
Browser chrome 版本 91.0.4472.124(正式版本) (64 位)
zorro-bot[bot] commented 3 years ago

Translation of this issue:

When using NZ-Cascader in the template driver form, set the NGMODEL default value.

reproduction link

[https://angular-w6gvrh.stackblitz.io] (https://angular-w6gvrh.stackblitz.io)

steps to reproduce

  1. New Template Drive Form
  2. Add NZ-Cascader in NZ-Form-Control and set ngmodel
  3. View the selected status (Value set by NGModel)
  4. The same NZ-Cascader in the Formographics can be selected

What is expected?

Template driver form correctly retro the segment field

What is actually happens?

Template driver form is not correct to the changing field

ENVIRONMENT INFO
Ng-Zorro-ANTD 11.4.1
Browser Chrome version 91.0.4472.124 (official version) (64-bit)
Feng-JY commented 3 years ago

控制台有报错,在元素上使用 [(ngModel)] 时,必须为该元素定义一个 name 属性 https://angular.cn/guide/forms#naming-control-elements

vthinkxie commented 3 years ago

请按照 @Feng-JY 建议进行修改