angular - 无法从 app.module.ts 文件配置 ngx-ui-loader
问题描述
我正在为我的 Angular 7 项目使用ngx ui 加载程序。
在app.module.ts文件中,我已经像这样导入了 ngx-ui-loader 包:-
import { NgxUiLoaderModule, NgxUiLoaderHttpModule, NgxUiLoaderConfig, SPINNER, POSITION, PB_DIRECTION } from 'ngx-ui-loader';
然后我创建了一个像这样的常量来定义配置参数:-
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
};
然后NgxUiLoaderModule.forRoot(ngxUiLoaderConfig)
在导入数组中添加@NgModule
在app.component.html文件中,我在<ngx-ui-loader></ngx-ui-loader>
标签上方添加了<router-outlet></router-outlet>
标签。
在app.component.ts文件中,我保留了以下代码
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 属性也不会改变。
我究竟做错了什么?
注意:请不要提出“为什么不使用其他加载器,如 http-loader 等”之类的建议。问题是关于为什么 ngx ui 加载程序没有按预期工作。
解决方案
您需要将 bgs 的所有实例更改为 fgs,因此 bgsColor 应该是 fgsColor。
默认情况下,唯一可见的微调器似乎是前景微调器和进度条。
希望有帮助
推荐阅读
- html - 使用 unpkg 在 html 中重用 Vue 组件
- javascript - React 状态从另一个状态变量(React Select)更新所有先前的元素
- javascript - 从数据库中获取 2 个计数器
- laravel - 即使 vue 中有数据,长度也为 0
- sql - 使用 SQL 将数据从行转换为列
- algorithm - 这是什么类型的排序算法
- python - 发生异常:InvalidArgumentError 您必须使用 dtype 字符串和形状 [1] 为占位符张量“Placeholder”提供一个值
- ruby - docker-compose build failed - http://security.debian.org/dists/jessie/updates/InRelease 的发布文件已过期
- ios - 如何在 UITableViewCell 中添加值
- node.js - 如何在 Node.js 中保存流?