11

I am trying to use the sample provide in here, but somehow I am not able to get it work with ng-templates. modified the stackblitz provided in example and tried but no luck. please help me to figure out what am I missing Below is my header code

<p-menubar [model]="items">
  <ng-template pTemplate="start">
    <img src="assets/showcase/images/primeng.svg" height="40" class="p-mr-2">
  </ng-template>
 <ng-template pTemplate="end">
    <input type="text" pInputText placeholder="Search">
 </ng-template>
</p-menubar>

outputMy local packages are

 {
"@angular/animations": "~9.1.3",
"@angular/common": "~9.1.3",
"@angular/compiler": "~9.1.3",
"@angular/core": "~9.1.3",
"@angular/forms": "~9.1.3",
"@angular/platform-browser": "~9.1.3",
"@angular/platform-browser-dynamic": "~9.1.3",
"@angular/router": "~9.1.3",
"ngx-electron": "^2.2.0",
"primeicons": "^4.1.0",
"primeng": "^11.4.0",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
}

Template shown in primeng docs

Krishna
  • 1,945
  • 1
  • 13
  • 24

2 Answers2

16

Updating the answer based on comment: One module import was missing in app.module.ts's imports array which is required for the desired output. So, please import TabViewModule and add it into the import array.

Adding the imports array:

  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MenubarModule,
    InputTextModule,
    TabViewModule,
  ]

and HTML template:

<p-menubar [model]="items">
  <ng-template pTemplate="start">
    <img src="assets/primeng.svg" height="40" class="p-mr-2">
  </ng-template>
  <ng-template pTemplate="end">
    <input type="text" pInputText placeholder="Search">
  </ng-template>
</p-menubar>

Please refer to updated demo link in here.

Demo image for reference: enter image description here

Mir entafaz Ali
  • 927
  • 6
  • 13
5

While importing TabViewModule (in Ali's answer) makes the problem go away, I think it's enough to import SharedModule from primeng/api (TabViewModule imports SharedModule which has the necessary PrimeTemplate class defined).

muczy
  • 51
  • 1
  • 2