我有一个TabService
将标签注入到mat-tab-groups
,
在构造函数中,我从 @angular/core 注入了 Injector 实例
constructor(
private loader: NgModuleFactoryLoader,
private injector: Injector
) {}
然后我使用 create 方法创建新选项卡或注入现有选项卡,如下所示:
private openInternal(newTab: OpenNewTabModel, moduleFactory?: NgModuleFactory<any>) {
const newTabItem: TabItem = {
label: newTab.label,
iconName: newTab.iconName,
component: {
componentType: newTab.componentType,
moduleFactory: moduleFactory,
injector: newTab.data
? Injector.create(newTab.data, this.injector)
: this.injector
}
};
我收到了这个警告:
{
"resource": "/.../tab.service.ts",
"owner": "typescript",
"code": "1",
"severity": 4,
"message": "create is deprecated: from v5 use the new signature Injector.create(options) (deprecation)",
"source": "tslint",
"startLineNumber": 51,
"startColumn": 22,
"endLineNumber": 51,
"endColumn": 28
}
新签名是Injector.create
什么?