angular - 如何使用 Angular 6 刷新依赖的 ng-tabs
问题描述
我使用ng-boostrap来显示带有 Angular 6 的选项卡。
我有 2 个选项卡,类别和类别设置。
在类别中,我可以添加或删除类别。在 CategoriesSettings 中,我可以配置每个类别。
这是如果我添加/删除一个类别,然后转到 categoriesSettings,我收到一个错误:
NgbTabset.html:4 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'active: false'. Current value: 'active: true'.
我可以理解,因为我在另一个选项卡中更改了 Categories Array 的值。
错误消息不是告诉我有关类别数组的信息,而是告诉我一个名为 active 的布尔值,它允许我记住活动选项卡。
此外,每个选项卡都是不同的组件。
我该怎么做?
这是一段代码:
<ngb-tabset type="pills" class="nav-fill" #tabs [activeId]="selectedTab" >
<ngb-tab id="categories">
<ng-template ngbTabTitle>{{ 'model.categories' | translate | uppercase }}</ng-template>
<ng-template ngbTabContent>
<div class="card mt-3">
<div class="card-body">
<form (ngSubmit)="onSubmitCategories()">
<app-tournament-edit-categories
[(ngModel)]="data.tournament" name="tournament"
[tournament]="data.tournament"
[categories]="data.categories">
</app-tournament-edit-categories>
<div align="right">
<button type="submit" class="btn btn-success">
{{ 'common.save' | translate }}
</button>
</div>
</form>
</div>
</div>
</ng-template>
</ngb-tab>
<ngb-tab id="category-settings">
<ng-template ngbTabTitle>{{ 'model.categorySettings' | translate | uppercase }}</ng-template>
<ng-template ngbTabContent>
<div class="card mt-3">
<div class="card-body">
<!--TODO When clicked, must refresh the page, as it could be changed with edit categories page-->
<app-tournament-edit-category-settings
*ngFor="let championship of data.tournament.championships; index as i"
[championship]="championship"
[i]="i"
>
</app-tournament-edit-category-settings>
</div>
</div>
</ng-template>
</ngb-tab>
</ng-tabset>
您需要查看组件吗?
解决方案
推荐阅读
- ansible - Ansible - 如何为角色依赖创造条件
- php - 如何使用jquery处理与选择标签相关的多个事件
- windows - 放入特定文件夹时自动将文件设置为只读
- typescript - Typescript 期望 mockImplementation 为所有方法和属性提供模拟
- swift - 是否可以在 init 中访问 enviromentObject 变量?
- tfs - 如何在 powershell 脚本中传递 TFS 2018 密码(隐藏)变量
- php - 如何获取我的查询返回的行数?
- node.js - AWS iam.deleteAccessKey 在 Node10 Lambda 中不可靠
- c - 在链接/编译时静态包含所有库而不是库的一部分
- sql-server - 作为服务运行时 ODBC SQLDriverConnect 崩溃