Open nth-commit opened 7 years ago
Yea, def the preferred way, just havent gotten round to it yet. This is what I have in mind though:
Add an @Input binding that expects a function that returns an observable string. Whenever a navigation event is triggered, this input function will be called with the url of the route. Thus its up to the parent app to map its own url/route names in this method and return the result as an observable.
<breadcrumb [routeName]="getRouteName"></breadcrumb>
getRouteName(url:string):Observable<string> {
return new Observable<string>((observer: Subscriber<string>) => {
var name:string = '';
if ('/comp1' == url) {
name = 'Comp 1';
} else if (new RegExp('^/comp1/comp[0-9]$').exec(url)) {
name = 'Comp 2';
}
observer.next(name);
});
}
A few minutes ago I have added the possibility to set Observable
And I have modified the component to use Observable
+1 If you could share your solution in any way, that would be great.
First basic test worked. If i simply put a string into the observable and used the async pipe. But when I started to put in an Observable comming from an Http-Request, which means having an delay it landed in an endless loop caused by some kind of recursion. The problem here was that I couldn't resolve where the source of the recursion occured. So my solution isn't working. But I will build an own component and share the source. Sorry for that.
+1 Any progress on this?
+1 This is much needed
+1 waiting for this
Rather than synchronous callback, it really needs to be able to return an Observable/Promise.