I am trying to make a breadcrumb component for angular7 but I can't get my array to properly show into my HTML and would like some tips because I can't find it on the internet. if you would be so kind as to help me I am still new to angular and can't think of a better way to make a breadcrumb component.
my component.ts -
breadcrumbLists: Array <any> = []; breadcrumburl: Array <any> = []; constructor(private _router: Router) { } ngOnInit() { this.listenrouting(); } listenrouting(): void { let routerUrl: string, routerList: Array < any > ; let i; let done; this._router.events.subscribe((router: any) => { routerUrl = router.urlAfterRedirects; if (routerUrl && typeof routerUrl === 'string') { this.breadcrumbLists.length = 0; routerList = routerUrl.slice(1).split('/'); this.breadcrumbLists = routerList; if (done != false) { this.breadcrumbLists.forEach(bread => { if (i != null) { this.breadcrumburl.push([{ name: bread }, { url: i + "/" + bread }]) } else { this.breadcrumburl.push([{ name: bread }, { url: "/" + bread }]) } i = "/" + bread }); } console.log("url", this.breadcrumburl) console.log(this.breadcrumbLists) done = false; } }); } and then my HTML -
<nav> <div> <li *ngFor="let Breadcrumb of breadcrumburl"> <a routerLink="{{Breadcrumb.url}}">{{Breadcrumb.name}}</a> </li> </div> </nav>
Breadcrumb.url- missed the capitalB