I want to create a directive that I can use a template variable with so that I can get access to a global variable, similar to $rootScope
in Angular.JS, without having to inject a service in every component that I need the variable in.
For instance:
@Directive({
selector: '[app]',
exportAs: 'app'
})
export class AppDirective {
isLoggedIn: boolean = false;
constructor() {
// Do some stuff to set 'this.ready'...
}
}
I want to be able to use the above code in my template like so:
<div #app>
<div *ngIf="app.isLoggedIn">...</div>
</div>
Is something like this possible?