Giter Club home page Giter Club logo

Comments (15)

vishnu-dev avatar vishnu-dev commented on May 29, 2024 16

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.

Adel-El-Sherif avatar Adel-El-Sherif commented on May 29, 2024 5

I had the same issue but was not resolved by @vishnu-dev 's solution, why?!

from xng-breadcrumb.

sagar1987 avatar sagar1987 commented on May 29, 2024 3

@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.

salaiviswatech avatar salaiviswatech commented on May 29, 2024 3

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.

udayvunnam avatar udayvunnam commented on May 29, 2024 1

@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.

udayvunnam avatar udayvunnam commented on May 29, 2024

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.

sagar1987 avatar sagar1987 commented on May 29, 2024

@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.

udayvunnam avatar udayvunnam commented on May 29, 2024

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

  1. git clone https://github.com/udayvunnam/xng-breadcrumb.git && git checkout 2.x
  2. npm i
  3. 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.

sagar1987 avatar sagar1987 commented on May 29, 2024

@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 :
OnNormalNavigationWithOutRefresh
On Refresh :
OnRefresh

from xng-breadcrumb.

dedrazer avatar dedrazer commented on May 29, 2024

I had the same issue and solved it using @vishnu-dev's solution

from xng-breadcrumb.

Daniyal1123 avatar Daniyal1123 commented on May 29, 2024

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.

udayvunnam avatar udayvunnam commented on May 29, 2024

@Daniyal1123 this is xng-breadcrumb repository.

please check the documentation https://udayvunnam.github.io/xng-breadcrumb/#/quickstart

from xng-breadcrumb.

udayvunnam avatar udayvunnam commented on May 29, 2024

@Adel-El-Sherif @Daniyal1123 can you please provide a reproducible example where you see this issue.

from xng-breadcrumb.

Daniyal1123 avatar Daniyal1123 commented on May 29, 2024

@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.

VISHAL69 avatar VISHAL69 commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.