小编Shi*_*hra的帖子

如何在单击按钮时以角度有条件地加载组件

我对 Angular 很陌生。

我想通过单击按钮在组件内有条件地加载子组件。单击按钮时,它应该重新渲染相应的子组件。

HTML代码

<div class="tab">
  <button class="tablinks" (click)="onTabClick('0')">Transmit</button>
  <button class="tablinks" (click)="onTabClick('1')">Published</button>
  <button class="tablinks" (click)="onTabClick('2')">Bulk Transmit</button>
</div>
<div>
  <app-sports  *ngIf="tabIndex === 0"></app-sports>
  <app-movies  *ngIf="tabIndex === 2"></app-movies>
</div>
Run Code Online (Sandbox Code Playgroud)

TS文件

tabIndex = 2 ;


  onTabClick(index){
        this.tabIndex = index;
   }
Run Code Online (Sandbox Code Playgroud)

javascript angular

2
推荐指数
1
解决办法
5083
查看次数

如何在5个以上的动作中使用ofType?

我必须在超过5个动作中使用ofType。

@Effect()
  applyInspectionsFilters$: Observable<Action> = this.actions$.pipe(
    ofType(
      InspectionsPageActions.applyInspectionsFilters.type,
      InspectionsPageActions.clearSelectedInspectionsFilters.type,
      InspectionsPageActions.removeSelectedStatusFilter.type,
      InspectionsPageActions.removeSelectedAttributeFilter.type,
      InspectionsPageActions.removeSelectedUserFilter.type,
      InspectionsPageActions.removeNotAssignedUsersFilter.type
    ),
    withLatestFrom(
      this.store$.pipe(select(fromInspections.getSelectedInspectionsFilters))
    ),
    switchMap(([action, filters]) =>
      ...
    )
  );
Run Code Online (Sandbox Code Playgroud)

当其库中参数的最大数量为5时,该怎么办?

typescript ngrx ngrx-effects angular

2
推荐指数
1
解决办法
164
查看次数

标签 统计

angular ×2

javascript ×1

ngrx ×1

ngrx-effects ×1

typescript ×1