码迷,mamicode.com
首页 > 其他好文 > 详细

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:45:16      阅读:785      评论:0      收藏:0      [点我收藏+]

标签:mode   char   解决   efi   either   change   sed   内容   core   

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.

标签:mode   char   解决   efi   either   change   sed   内容   core   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!