One of my components gets an array of items. Each item has a permission, which will be checked by a rest call based on the user role. If the user is permitted for the item, it can be displayed.
So I came along with this approach:
ngOnInit(): void {
for( let tile of this.tiles ) {
this.permissionCheckService.isUserPermitted( tile.name ).subscribe(
isPermitted => tile.show = isPermitted
)
}
}
But this solution introduces a new variable "show". Maybe it would be even better if the items, which should not be displayed, will be removed from the array?
Next step should be to implement a loading indicator. This indicator should be removed, if all requests are finished. But my problems starts here. I think I have to combine all observables, but i don't know how to do it.
Here is a working example: https://stackblitz.com/edit/angular-wfjj5n-horatl?embed=1&file=src/app/alert-basic.ts