我想通过单击按钮图标重新加载组件视图,而不刷新整个页面。
我的查看代码:
<nb-card>
<nb-card-header>
<div class="row" style="font-size: 2.125rem !important;">
<div class="col-sm-8">
Tableau des Casiers
</div>
<div class="col-sm-4 d-flex justify-content-end">
<nb-action icon="ion-refresh sizeicone" (click)="refresh()"></nb-action>
</div>
</div>
</nb-card-header>
<nb-card-body>
<ng2-smart-table [settings]="settings" (custom)="onCustom($event)" [source]="source"
(deleteConfirm)="onDeleteConfirm($event)" (editConfirm)="onSaveConfirm($event)"
(createConfirm)="onCreateConfirm($event)">
</ng2-smart-table>
</nb-card-body>
</nb-card>
Run Code Online (Sandbox Code Playgroud)
Kam*_*ski 11
在 angular 中,您不需要刷新组件 - 当它检测到模板上使用的变量发生变化时,angular 会自动刷新页面内容。所以在refresh()
方法中只更新变量值。但是,如果您真的想手动执行此操作,则可以使用以下构造:
模板:
<my-component *ngIf="showComponent"></my-component>
Run Code Online (Sandbox Code Playgroud)
.ts 文件:
public refresh() {
this.showComponent=false;
setTimeout(x=>this.showComponent=true);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9607 次 |
最近记录: |