Angular 7 - ngx-spinner覆盖整个页面
创始人
2024-10-16 15:00:50
0

要在整个页面上使用ngx-spinner覆盖,您可以按照以下步骤进行操作:

  1. 首先,安装ngx-spinner库。您可以使用以下命令在您的Angular项目中安装它:
npm install ngx-spinner --save
  1. 在您的app.module.ts文件中导入ngx-spinner模块:
import { NgxSpinnerModule } from 'ngx-spinner';

@NgModule({
  imports: [
    NgxSpinnerModule
  ],
  //...
})
export class AppModule { }
  1. 在您希望使用加载器的组件的ts文件中导入ngx-spinner服务和Spinner类型:
import { Component, OnInit } from '@angular/core';
import { NgxSpinnerService } from 'ngx-spinner';
import { Spinner } from 'ngx-spinner/lib/ngx-spinner.enum';

@Component({
  selector: 'app-your-component',
  templateUrl: './your-component.component.html',
  styleUrls: ['./your-component.component.css']
})
export class YourComponent implements OnInit {

  constructor(private spinnerService: NgxSpinnerService) { }

  ngOnInit() {
    this.spinnerService.show();
    // 执行需要一些时间的操作,例如从服务器获取数据
    setTimeout(() => {
      this.spinnerService.hide();
    }, 2000); // 设置2秒后隐藏加载器
  }

}
  1. 在您希望显示加载器的组件的HTML文件中添加ngx-spinner标记:

通过上述步骤,当您导航到该组件时,将在整个页面上显示ngx-spinner加载器,直到您隐藏它为止。

相关内容

热门资讯

1分钟辅助!aapoker a... 1分钟辅助!aapoker ai插件,哈糖大菠萝破解器,秘籍教程(有挂教学)哈糖大菠萝破解器能透视中...
两分钟辅助!hhpoker透视... 两分钟辅助!hhpoker透视脚本,拱趴大菠萝万能辅助器,方案教程(有挂细节)1、在拱趴大菠萝万能辅...
第三分钟辅助!werplan脚... 第三分钟辅助!werplan脚本,pokemmo辅助器,项目教程(有人有挂)进入游戏-大厅左侧-新手...
第四分钟辅助!约局吧游戏挂,悦... 第四分钟辅助!约局吧游戏挂,悦扑克脚本,举措教程(有挂方略)约局吧游戏挂破解侠是真的助透视。每个模型...
十分钟辅助!竞技联盟透视,we... 十分钟辅助!竞技联盟透视,wepoker-h5下载,积累教程(有挂解密)竞技联盟透视能透视中分为三种...
九分钟辅助!wepoker俱乐... 九分钟辅助!wepoker俱乐部辅助,wepoker模拟器哪个好用,窍要教程(真是有挂)在进入wep...
第一分钟辅助!悦扑克脚本,德州... 第一分钟辅助!悦扑克脚本,德州机器人代打脚本,学习教程(有挂秘笈)所有人都在同一条线上,像星星一样排...
五分钟辅助!wepoker私人... 五分钟辅助!wepoker私人局有透视吗,wepoker私人局开挂视频,技法教程(有挂教学)1、完成...
七分钟辅助!wepoker有机... 您好,wepoker有机器人吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
8分钟辅助!aapoker发牌... 8分钟辅助!aapoker发牌逻辑,wepoker透视脚本免费下载pc,练习教程(有挂技术)1)we...