首页 > 其他 > 详细

ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.

时间:2018-12-14 22:07:46      阅读:262      评论:0      收藏:0      [点我收藏+]

AbpCore 前端使用Ng-Zorro 日期控件nz-range-picker时属性[ngModel]和事件(ngModelChange)都不起作用

控件代码

  <nz-range-picker  [nzFormat]="shedateFormat" [ngModel]="searchAreasDate" (ngModelChange)="changeTime($event)"></nz-range-picker>

并且脚本报错,详细报错内容如下:

 ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as ‘standalone‘ in ngModelOptions.

Example 1: <input [(ngModel)]="person.firstName" name="first">

Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">

 

解决方法

仔细看看代码不难发现没有name属性,增加name属性后一切正常。

 

<nz-range-picker name="timeRangePicker" [nzFormat]="shedateFormat" [ngModel]="searchAreasDate"
                            (ngModelChange)="changeTime($event)"></nz-range-picker>

 

ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.

原文:https://www.cnblogs.com/Martincheng/p/10121635.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!