在我的应用我使用DI通过关于UserLogged信息需要这样的信息在不同的组件周围。 这意味着我有一个main.ts
类这样Angular2 - 使用依赖注入外组件
import {AppComponent} from './app.component';
import {UserLogged} from './userLogged'
bootstrap(AppComponent, [UserLogged]);
,并需要使用的UserLogged
实例的部件有这样
constructor(private _user: UserLogged)
构造现在我想使用相同的实例的UserLogged
也在简单的TypeScript类(它不是@Component
)。这可能吗?换句话说,如果我在@Component
之外,是否也可以获得由DI注入的UserLogged
的相同实例?