[英]Angular4 : PrimeNG not work
我尝试将 PrimeNG 集成到我的项目 angular4 中,我按照网站中的设置进行了操作,但是当我导入一个模块时,它会显示一条错误消息,例如:
Can't bind to 'ngModel' since it isn't a known property of 'p-inputSwitch'.
home.module.ts
import { NgModule } from '@angular/core';
import { ChartsModule } from 'ng2-charts/ng2-charts';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { HomeComponent } from './home.component';
import { HomeRoutingModule } from './home-routing.module';
import {InputSwitchModule} from 'primeng/primeng';
@NgModule({
imports: [
HomeRoutingModule,
ChartsModule,
BsDropdownModule,
InputSwitchModule
],
declarations: [ HomeComponent ]
})
export class HomeModule { }
home.component.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
templateUrl: 'home.component.html'
})
export class HomeComponent implements OnInit {
// constructor( ) { }
checked1: boolean = false;
checked2: boolean = true;
/
.
.
.
/
}
主页.component.html
<h3 class="first">Basic - {{checked1}}</h3>
<p-inputSwitch [(ngModel)]="checked1"></p-inputSwitch>
<h3>Labels - <span> {{checked2}}</span></h3>
<p-inputSwitch onLabel="Yes" offLabel="No" [(ngModel)]="checked2"></p-inputSwitch>
如果您没有导入“FormsModule”,您将看到此消息。 对于你的情况,我没有看到这一点。
Can't bind to 'ngModel' since it isn't a known property of X.
此消息表明找不到“ngModel”的声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.