Anas
Anas

Reputation: 75

Angular4 : PrimeNG not work

I try to integrate PrimeNG in my project angular4, I followed setup in the website but when I import a module it displays an error message, for example:

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>

Upvotes: 1

Views: 868

Answers (1)

Val
Val

Reputation: 22797

You will see this message if you didn't import "FormsModule". For your case I didn't see that in place.

Can't bind to 'ngModel' since it isn't a known property of X.

This message shows that the declaration of 'ngModel' cannot be found.

Upvotes: 4

Related Questions