In my app I use DI to pass information about the UserLogged around the different Components that need such info.
This means that I have a main.ts
class like this
import {AppComponent} from './app.component';
import {UserLogged} from './userLogged'
bootstrap(AppComponent, [UserLogged]);
and the components that need to use the instance of UserLogged
have a constructor like this
constructor(private _user: UserLogged)
Now I would like to use the same instance of UserLogged
also in simple TypeScript classes (which are not @Component
). Is this possible? In other words, can I get hold of the same instance of UserLogged
injected by DI also if I am outside a @Component
?