Closed sagar1987 closed 5 years ago
Hey @sagar1987, can you let me know which version of xng-breadcrumb you are using. If you are using old version suggest you to update to latest one. The issue was fixed long ago in https://github.com/udayvunnam/xng-breadcrumb/issues/1
@udayvunnam Hi Uday thanks for the reply , I am using version "xng-breadcrumb": "^2.1.0" , Please let me know how can i resolve this issue . Thanks in advance
Hey @sagar1987, can you please provide your sample route and breadcrumb configuration. As I see with xng-breadcrumb@2.1.2 and Angular 7, page refresh doesn't hide/disappear breadcrumb. If you need a reference for demo app please follow the steps
Now the demo app opens and showcases the library usage.
You can move to any route(even deep routes like http://localhost:4200/mentee/1/edit) and refresh. The breadcrumb still shows.
Please let me know if I am missing something or your breadcrumb configuration is different than usual.
This is my part of route
In Route module @NgModule({ imports: [ RouterModule.forRoot(routes, { useHash: false })], exports: [RouterModule] }) export class AppRoutingModule {
constructor(private translate: TranslateService) {}
In component in ngOnInit() this.breadcrumbService.setForAlias('managesubscription', 'TEST123');
It works fine on initial load and while navigation the only problem is when i refresh the page , I think during page refresh this.breadcrumbService doesnt work , May be the refresh issue in angular for state management using services ? , Not sure how it works for you am i missing some configuration for page refresh in routing . ?
And i also notice that the array currentBreadcrumbs inside the this.breadcrumbService is empty when i refresh the page .Please find the below screen shots WithOutRefresh : On Refresh :
@sagar1987 I think I understood your problem. The breadcrumb which is set dynamically in component is lost and not shown when refreshed.
The problem is where you set the this.breadcrumbService.setForAlias('managesubscription', 'TEST123')
You can move up the logic this.breadcrumbService.setForAlias() or this.breadcrumbService.set()
to it's nearest parent which is always in the view no matter whichever child is rendered.
@udayvunnam Perfect answer , Yes i just injected the breadcrumbService into the constructor of AppComponent and the breadcrumbs value gets retained even on page refresh , So then the AppComponent always get loaded into the view when the page is reloaded/refreshed , Thanks a lot @udayvunnam for you valuable suggestions 💯 🥇
To persist breadcrumb on refresh, Add below code to your parent component, mostly app.component.ts
. In the docs it is mentioned as optional, but it seems without that the breadcrumb is not persisted on refresh.
(Optional) Use BreadcrumbService, if you want to change breadcrumbs behavior(visibility, label, etc) dynamically. X
import { BreadcrumbService } from 'xng-breadcrumb';
constructor(private breadcrumbService: BreadcrumbService) {}
I had the same issue and solved it using @vishnu-dev's solution
I had the same issue but was not resolved by @vishnu-dev 's solution, why?!
Hey Guys when i Used @vishnu-dev 's Solution it shows
**Failed to compile.
./node_modules/xng-breadcrumb/fesm2015/xng-breadcrumb.mjs 322:145-162 Can't import the named export 'ActivatedRoute' from non EcmaScript module (only default export is available)**
Can someone please help i am facing issue when page refreshes breadcrumbs Disappears i am using "ng-dynamic-breadcrumb": "^3.0.1",
@Daniyal1123 this is xng-breadcrumb
repository.
please check the documentation https://udayvunnam.github.io/xng-breadcrumb/#/quickstart
@Adel-El-Sherif @Daniyal1123 can you please provide a reproducible example where you see this issue.
@udayvunnam same happening in Xng
ERROR in ./node_modules/xng-breadcrumb/fesm2015/xng-breadcrumb.mjs 322:145-162 Can't import the named export 'ActivatedRoute' from non EcmaScript module (only default export is available) ERROR in ./node_modules/xng-breadcrumb/fesm2015/xng-breadcrumb.mjs 329:58-75
Hii @udayvunnam
i am facing an issue, i have a nested routing with query params like "abd/pqr?usedId=2" and on next level of nesting the route becomes "abd/pqr/xyz?userId=2" so the first breadcrumb holds the route as "abd/pqr?usedId=2" and as i reload the page first breadcrumb that holds route becomes "abd/pqr" as it losses its query param but if i didn't refresh the page it work excellent as expected
Hi @udayvunnam
If we are refreshing the page , the child route dynamic breadcrumb does not load at all. It works for parent routing. can you explain how it is working or share any demo related to that? In your repo, I don't see alias based breadcrumb label used in nested routes. Appreciate if you share any.
@udayvunnam Hi I am facing issues when i refresh the browser page , the breadcrumb disappears any fix for this issue , Please let me know thanks