Comments (15)
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) {}
from xng-breadcrumb.
I had the same issue but was not resolved by @vishnu-dev 's solution, why?!
from xng-breadcrumb.
@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 💯 🥇
from xng-breadcrumb.
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.
from xng-breadcrumb.
@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')
- When you move from one route to another we store all the dynamically set labels and show them in Breadcrumb.
- But when you refresh, you have to make sure the component where you have set the dynamic label is loaded into the view.
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.
from xng-breadcrumb.
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 #1
from xng-breadcrumb.
@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
from xng-breadcrumb.
Hey @sagar1987, can you please provide your sample route and breadcrumb configuration. As I see with [email protected] and Angular 7, page refresh doesn't hide/disappear breadcrumb. If you need a reference for demo app please follow the steps
- git clone https://github.com/udayvunnam/xng-breadcrumb.git && git checkout 2.x
- npm i
- ng serve
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.
from xng-breadcrumb.
@udayvunnam
This is my part of route
{
path: "manage-subscriptions",
children: [
{
path: '',
component: CustomerSearchComponent,
data:
{
breadcrumbAlias: 'managesubscription'
}
},
{
path: 'saved-carts/:cdbId/:countryCode/:name',
component: CartComponent,
//canActivate: [AuthGuard],
data:
{
breadcrumbAlias: 'savedcarts'
}
},
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 :
from xng-breadcrumb.
I had the same issue and solved it using @vishnu-dev's solution
from xng-breadcrumb.
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",
from xng-breadcrumb.
@Daniyal1123 this is xng-breadcrumb
repository.
please check the documentation https://udayvunnam.github.io/xng-breadcrumb/#/quickstart
from xng-breadcrumb.
@Adel-El-Sherif @Daniyal1123 can you please provide a reproducible example where you see this issue.
from xng-breadcrumb.
@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
from xng-breadcrumb.
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
from xng-breadcrumb.
Related Issues (20)
- Unable to setup breadcrumb for certain route paths HOT 7
- Breadcrumbs are not displayed for lazy loaded module HOT 3
- update xng-breadcrumb demo app that uses Material UI HOT 7
- Module not found when using BreadcrumbService from another module in which the BreadCrumbsModule is imported HOT 2
- Set multiple breadcrumbs regardless of route HOT 11
- Need docs! HOT 2
- xng-breadcrumb not working in Angular Ionic HOT 2
- Hiding the breadcrumbs with one level only HOT 3
- Breadcrumb doesn't work on routes using `matcher` HOT 5
- Property '"autoGenerate"' is incompatible with index signature. HOT 3
- Double rendering with provideClientHydratation Angular 16 HOT 4
- Customizing breadcrumb HOT 3
- Breadcrumb Links Not Working HOT 4
- Breadcrumb labels no longer working with loadChildren HOT 5
- Duplicate breadcrumbs on Angular 17 HOT 6
- Support for Angular 17 HOT 16
- Typo in Dynamic breadcrumbs example HOT 1
- Custom aria-label for accessibility in other languages HOT 2
- Breadcrumb temporarily disappears during resolver data loading HOT 1
- Angular 17: Module '"xng-breadcrumb"' has no exported member 'BreadcrumbModule'. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xng-breadcrumb.