本文介绍了无法从app.module.ts文件配置ngx-ui-loader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的angular 7项目使用 ngx ui加载器.

I am using the ngx ui loader for my angular 7 project.

app.module.ts 文件中,我已导入ngx-ui-loader程序包,如下所示:-

In the app.module.ts file, I have imported the ngx-ui-loader package like this:-

import { NgxUiLoaderModule, NgxUiLoaderHttpModule, NgxUiLoaderConfig, SPINNER, POSITION, PB_DIRECTION } from  'ngx-ui-loader';

然后我创建了一个像这样的常量来定义配置参数:-

Then I created a constant like this to define the configuration parameters:-

const ngxUiLoaderConfig: NgxUiLoaderConfig = {
  bgsColor: 'red',
  bgsPosition: POSITION.bottomCenter,
  bgsSize: 40,
  bgsType: SPINNER.rectangleBounce,
  pbDirection: PB_DIRECTION.leftToRight, // progress bar direction
  pbThickness: 5, // progress bar thickness
};

然后在 @NgModule

app.component.html 文件中,我在上面的< ngx-ui-loader></ngx-ui-loader> 标记中添加了< router-outlet></router-outlet> 标记.

In the app.component.html file, I have added the <ngx-ui-loader></ngx-ui-loader> tag just above the <router-outlet></router-outlet> tag.

app.component.ts 文件中,我保留了以下代码

In the app.component.ts file, I kept the following code

import { NgxUiLoaderService } from 'ngx-ui-loader';

export class AppComponent implements OnInit{
  title = 'medico';
  constructor(private ngxService: NgxUiLoaderService) { }
  ngOnInit() {
    this.ngxService.start(); // start foreground spinner of the master loader with 'default' taskId
    // Stop the foreground loading after 5s
    setTimeout(() => {
      this.ngxService.stop(); // stop foreground spinner of the master loader with 'default' taskId
    }, 300);
  }
}

运行页面时,我可以看到加载程序.问题是,即使更改了app.module.ts中的配置数据,loader属性也不会更改.

When I am running the page, I can see the loader. The issue is, even after changing the configuration data in the app.module.ts, the loader property doesn't change.

我在做什么错了?

注意:请不要给出为什么不使用http-loader之类的其他加载器"之类的建议.问题是为什么ngx ui加载程序无法正常工作.

Note: Please don't give suggestions like "why don't you use other loader like http-loader, etc". The question is about why the ngx ui loader isn't working as expected.

推荐答案

您需要将bgs的所有实例都更改为fgs,因此bgsColor应该为fgsColor.

You need to change all instances of bgs to fgs, so bgsColor should be fgsColor.

默认情况下,唯一可见的微调框是forground微调框和进度条.

By default, the only spinner viewable appears to be the forground spinner and the progress bar.

希望有帮助

这篇关于无法从app.module.ts文件配置ngx-ui-loader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:31