Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度7重新加载组件视图_Angular - Fatal编程技术网

Angular 角度7重新加载组件视图

Angular 角度7重新加载组件视图,angular,Angular,我想通过单击按钮图标重新加载组件视图,而不刷新整个页面 我的视图代码: <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="c

我想通过单击按钮图标重新加载组件视图,而不刷新整个页面

我的视图代码:

<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>

卡塞尔斯表

在angular中,您不需要刷新组件-angular检测到模板上使用的变量发生更改时,将自动刷新页面内容。所以在
refresh()
方法中只需更新变量值。但是,如果确实要手动执行,则可以使用以下构造:

模板:

<my-component *ngIf="showComponent"></my-component>

我也在考虑同样的技巧,比如hackish样式,但是它很好地工作,但是有时候你可以看到组件消失/出现。
public refresh() {
   this.showComponent=false;
   setTimeout(x=>this.showComponent=true);
}