My service retrieves permissions for the currently logged-in user as a record. The necessary observable is declared in my TypeScript file as a member variable:
permissionsRecord$: Observable<Record<string, boolean>>;
When I call the service, I send an array of authorizations to be checked. In this scenario, I am checking only for the "updateInterval" permission:
constructor() {
this.permissionsRecord$ = this.japs.userHasPermissionForActions([root.scheduler.order.updateInterval]);
}
The record returned by the service has the authorization as the key to be checked. The value can either be true or false. I intend to access this record from my template file like so:
<app-scheduler [allowDragAndDrop]="(permissionsRecord$ | async)[root.scheduler.order.updateInterval]">
Although it seems to be functioning correctly, I am seeing an error in the console.
SchedulerComponent.html:4 ERROR TypeError: Cannot read property 'scheduler.order.updateInterval' of null
at Object.eval [as updateDirectives] (SchedulerComponent.html:13)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:45258)
at checkAndUpdateView (core.js:44270)
at callViewAction (core.js:44636)
at execComponentViewsAction (core.js:44564)
at checkAndUpdateView (core.js:44277)
at callViewAction (core.js:44636)
at execEmbeddedViewsAction (core.js:44593)
at checkAndUpdateView (core.js:44271)
at callViewAction (core.js:44636)
I am unsure if my code is accurate. How can I properly access the record within the observable using async from the template?