0
我尝试PrimeNG在我的项目angular4整合,我跟着网站的设置,但是当我导入一个模块,它会显示错误消息,例如:Angular4:PrimeNG不行
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;
/
.
.
.
/
}
home.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>
您是否为ngModel导入FormModule? – Val
感谢您的回答,我不得不将FormModule导入到全局模块中,并且当我将FormModule导入到home.module.ts时,它的工作原理是 – Anas