0

我试图ProductListComponent用自定义替换。问题是当我转到 url 时,例如http://localhost:4200/c/584,激活的路由没有任何参数。但我期待categoryCodebrandCode。什么问题?

组件代码:

export class CustomProductListComponent extends ProductListComponent implements OnInit, OnDestroy {
  private sub: Subscription;
  constructor(..) {..}
  ngOnInit(): void {
    this.sub = this.activatedRoute.params.subscribe(params => {
      this.activeFacetValueCode = params.categoryCode || params.brandCode;
    });
    super.ngOnInit();
  }
  ngOnDestroy() {
    if (this.sub) {
      this.sub.unsubscribe();
    }
  }
}

配置:

ConfigModule.withConfig({
      cmsComponents: {
        CMSProductListComponent: {
          component: CustomProductListComponent
        },
        ProductRefinementComponent: {
          component: CustomProductFacetNavigationComponent
        }
      }
})
4

1 回答 1

0

我通过调用获取活动路线数据替换Subscription了对象。ProductListComponentService

于 2020-03-10T13:20:45.430 回答