Ng-zorro-antd: 子路由中datepicker组件报错

Created on 16 Aug 2017  ·  2Comments  ·  Source: NG-ZORRO/ng-zorro-antd

项目中有嵌套路由,首先在app.component.html中引入跟组件:
<nz-root> <router-outlet></router-outlet> </nz-root>
并在根 module 和子module都引入了NgZorroAntdModule
在子module调用datepicker
<nz-datepicker [(ngModel)]="_date" [nzPlaceHolder]="'Select date'"></nz-datepicker>

chrome报错:

compiler.es5.js:1690 Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'nz-datepicker'.

  1. If 'nz-datepicker' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
  2. If 'nz-datepicker' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("

    {{item.name}}开始时间


    ][(ngModel)]="_date" [nzPlaceHolder]="'Select date'">

是我调用有什么问题吗?

Most helpful comment

If you want to use ngModel, you have to import FormsModule in your module

import { FormsModule } from '@angular/forms';

https://angular.cn/api/forms/FormsModule

All 2 comments

If you want to use ngModel, you have to import FormsModule in your module

import { FormsModule } from '@angular/forms';

https://angular.cn/api/forms/FormsModule

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings