Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'p-header' is not a known element in PrimeNg for Angular2 application

i am using PrimeNg for my angular2 project and i am trying to add panel in the page. I used below code for this which i took from primeng tutorial ( http://www.primefaces.org/primeng/#/panel ):-

my html file has below code :-

<p-panel>
   <p-header>
      Header content here
   </p-header>
  Body Content
</p-panel>

I have added imported required modules in my module from primeng :-

   import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
   import { MyComponent } from './my.component';
   import { CommonModule } from '@angular/common';
   import { SharedModule, PanelModule } from 'primeng/primeng';


 @NgModule({
  imports: [
    CommonModule, SharedModule, PanelModule
   ],
   declarations: [MyComponent],
   schemas: [CUSTOM_ELEMENTS_SCHEMA ]
   })
  export class ThemeModule { }

This is throwing below error in console :-

EXCEPTION: Uncaught (in promise): Error: Template parse errors: 'p-header' is not a known element: 1. If 'p-header' is an Angular component, then verify that it is part of this module. 2. If 'p-header' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("

like image 731
Rj-s Avatar asked Jan 23 '17 12:01

Rj-s


People also ask

What is PrimeNG library?

PrimeNG is a collection of rich UI components for Angular. All widgets are open source and free to use under MIT License. PrimeNG is developed by PrimeTek Informatics, a vendor with years of expertise in developing open source UI solutions.

What is PrimeNG?

PrimeNG is a rich set of open source native Angular UI components.


3 Answers

With 2.0-RC.1 primeng changed and to and if you upgrade your version it will work.

like image 189
Mertcan Diken Avatar answered Oct 18 '22 07:10

Mertcan Diken


Try to import SharedModule to solve this issue

import {ChartModule, CalendarModule, SharedModule} from 'primeng/primeng';

@NgModule({
imports: [
    CommonModule,
    FormsModule,
    CalendarModule,
    SharedModule,
],
like image 35
saravanakumar Avatar answered Oct 18 '22 06:10

saravanakumar


It was version issue. Its working with version 2.

like image 1
Rj-s Avatar answered Oct 18 '22 07:10

Rj-s