MenuBar - ngTemplate

UI Components for Angular
Post Reply
F0X
Posts: 2
Joined: 04 Sep 2020, 10:44

06 Sep 2020, 11:23

Hello all,
I try to customize a Menubar with icon, particularly using the ptemplate (created for that), like the primeng example (and the code from the source) :

Code: Select all

<p-menubar [model]="items">
            <ng-template pTemplate="start">
                [Image <i />]
            </ng-template>
            <ng-template pTemplate="end">
                <input type="text" pInputText placeholder="Search">
            </ng-template>
</p-menubar>
But when I use that in my project, it don't work...

For my configuration :
PrimeNg version : "primeng": "^10.0.0-rc.1",
In App.module : Import of MenuBarModule
In my TS File : Import of MenuItem from primeng/api.

There is only few documentation about the use of template for menu in primeNg.
So, why it don't work ?
- Need of importing another PrimeNg directive/file ?
- I use the basic version of PrimeNg : this pTemplate is only available for the Pro-versions ??
- The formulation 'pTemplate='start' change in the last versions of primeng ??

Thank you a lot !!

Cin
Posts: 1
Joined: 18 Sep 2020, 02:00

18 Sep 2020, 02:03

I ran into the same issue with the MegaMenu component. Looks like it's related to this issue:
https://github.com/primefaces/primeng/issues/8031

I'll log a ticket for these 2 components tonight, but in the meantime, the quickest fix is to make sure you import:

Code: Select all

import { SharedModule } from 'primeng/api';
in your module, and it'll start working.

rfwalker
Posts: 10
Joined: 19 Aug 2011, 21:40

14 May 2021, 17:56

this worked for me, thanks for the response, i was stuck getting

Code: Select all

<ng-template pTemplate="start">
        <img src="assets/images/my.png" height="40">
    </ng-template>
to work inside

Code: Select all

<p-menubar  [model]="items">

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests