Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
- ABP Framework version: v3.0.4
- UI type: Angular / MVC: Angular
- DB provider: EF Core / MongoDB
- Tiered (MVC) or Identity Server Seperated (Angular): yes / no:no
- Exception message and stack trace: Unable to remove dynamically added right menu Item?
- Steps to reproduce the issue:
As Per requirement we need to show notification Icon on after login, So I am adding menu item as follwing this document
https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-an-element-to-right-part-of-the-menu
In app.component.ts constructor( private navItems: NavItemsService) { navItems.addItems([ { id: 'notification-litmus', order: 1, component: LitmusNotificationComponent, }]) } Using NavItemService I added menu Item, It's adding after login, showing the menu item on menu as expected,
Issue: ngOninit hook of LitmusNotificationComponent calling even after logout, because of this whatever functions calling in oninit all are calling even after logout.
litmus-notification.component.ts export class LitmusNotificationComponent implements OnInit ngOnInit(): void { alert('oninit') } }
How to handle this? If need to remove item from navItems then How to do it ? , From Documentation I did not understood remove item from navItems?
Apart from this what I am doing wrong?
Kindly help"
2 Answer(s)
-
0
Hi @lalitChougule
ApplicationLayoutComponent
destroys when a user log out. Therefore, all subcomponents belonging to this component also destroy. When logging in again, all components are reinitialized. That's whyngOnInit
works again.You can remove a nav item with an
id
you defined when adding.constructor(private navItems: NavItemsService) { navItems.removeItem('notification-litmus'); }
-
0
Assuming your problem has been resolved, I am closing the question. Plase let me know if any problems arrise.