I have an array of routes, which I'm trying to filter on depending if the service says the user has permission. I've tried various combination & transformative operators with no success mergeMap, concatMap, concatAll, mergeAll
. The problem is that hasRoutePermission
returns an observable that returns a boolean from the endpoint. Thanks in advance.
stackblitz
const exampleRoutes = [{
model: 'ExampleModel'
}, {
model: 'ExampleModel'
}, {
model: 'ExampleModel'
}, {
model: 'ExampleModel'
}];
filterRoutes(routes): Observable <[]> {
const hasRoutePermission = (route: IRouteData): Observable <boolean> =>
this.examplePermissionService.hasRoutePermission(route);
return of(items)
.pipe(
filter(item => hasRoutePermission(item))// Problem is here
)
}
I'm using an async pipe to subscribe to the filtered list in the template.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…