3

我们正在尝试扩展 ProductListComponent,因此我们创建了:

export class CustomProductListComponent extends ProductListComponent {

  constructor(
    pageLayoutService: PageLayoutService,
    productListComponentService: ProductListComponentService
  ) {
    super(pageLayoutService, productListComponentService);
  }
}

但是 ProductListComponentService 是不可见的,所以我们决定用这个扩展 ProductListComponentService :

@Injectable({providedIn: 'root'})
export class CustomProductListComponentService extends ɵe {
  constructor(
    protected productSearchService: ProductSearchService,
    protected routing: RoutingService,
    protected activatedRoute: ActivatedRoute,
    protected currencyService: CurrencyService,
    protected languageService: LanguageService,
    protected router: Router
  ) {
    super(productSearchService, routing, activatedRoute, currencyService, languageService, router);
  }
}

但现在在扩展部分我们有这个奇怪的字符串 'ɵe'。扩展 ProductListComponent 的推荐方法是什么?为什么这个字符串 'ɵe' 在那里?

4

1 回答 1

2

ProductListComponentService 应该是公开的,所以它是一个错误 AFAIK。如果可以的话,请为此创建一个问题,我会尝试升级它。

目前,您可以通过私有符号 (ɵe) 使用该导入作为解决方法,但考虑到它可能会随着下一个 lib 版本而更改(因此在将 lib 更新到新版本时需要再次检查它)。不幸的是,目前没有更好的选择。

为了使其更易于阅读,您可以像这样导入它: import { ɵe as ProductListComponentService },因此至少在实际中extend您将能够使用正确的符号。

于 2019-09-23T08:14:34.763 回答