【问题标题】:ngx-loading, Angular 4. Jhipster 4.8.2. Not Show Spinnerngx 加载,Angular 4。Jhipster 4.8.2。不显示微调器
【发布时间】:2020-01-24 17:55:44
【问题描述】:

它会向您发送在我的 Jhipster 4.8.2 应用程序中安装 spinnner ngx-loading 的步骤,它不会给出错误并且看起来没问题,但它不会绘制微调器:

安装:

npm install --save ngx-loading

在 app.module.ts 中:

import { LoadingModule } from 'ngx-loading';
....
imports: [
    BrowserModule,
    LayoutRoutingModule,
    Ng2Webstorage.forRoot({ prefix: 'jhi', separator: '-' }),
    Crm482SharedModule,
    Crm482HomeModule,
    Crm482HomeRRHHModule,
    Crm482PrlModule,
    Crm482MainModule,
    Crm482AdminModule,
    Crm482AccountModule,
    Crm482EntityModule,
    SimpleNotificationsModule.forRoot(),
    LoadingModule
    // jhipster-needle-angular-add-module JHipster will add new module here
],

main.component.html:

<simple-notifications [options]="optionsNotifications"></simple-notifications>
<ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
<jhi-page-ribbon></jhi-page-ribbon>
<div>
  <router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
<!--I tried to put it here and it's not going-->
<div class="card jh-card">
    <router-outlet></router-outlet>
    <router-outlet name="popup"></router-outlet>
</div>
<jhi-footer></jhi-footer>
</div>

我的控制器:

export class MyControllerComponent implements OnInit, OnDestroy {

public loading = false;
......
ngOnInit() {
  this.loading = true;
  ....

【问题讨论】:

  • 是ngx-loading包,你的请求都使用HttpClientModule还是HttpModule? HttpClientModule 看不到使用 HttpModule 发出的请求,反之亦然。
  • 当我把 this.loading = true;当我把它放到 this.loading = false; .根据例子。你确定它依赖于“HttpClientModule 还是 HttpModule”?

标签: angular spinner jhipster


【解决方案1】:

在 main.component.ts 中(没有我的组件):

public loading = false;

 ....

public loader(loading:boolean) {
 this.loading = loading;
}

在 my.component.ts 中:

import {JhiMainComponent} from '../../../layouts/main/main.component';
....
this.jhiMainComponent.loader(true); // start
this.jhiMainComponent.loader(false); // finish

【讨论】:

  • 我可以在列表的
  • 标签中使用它吗?
【解决方案2】:

我刚刚阅读了documentation 并意识到你需要放置

<ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>

在您的模板组件中,而不是在主应用程序模板中。这意味着您需要为每个组件模板编写这个以及每个组件中的布尔变量。 (如果你问我,那就太乏味了)

我还推荐this package,因为您只需在应用程序组件中设置一次,它将适用于所有使用 HttpClientModule 的请求。

【讨论】:

  • 它不起作用,也无法将其添加到特定组件中。您提供的选项不是我需要的,我想在需要时放置微调器并将其删除,而不依赖于 HttpClientModule 或任何东西。非常感谢您的帮助。
【解决方案3】:

非常好的 ngx 加载...

安装:

npm i ngx-loading

app.module中:

import { LoadingModule, ANIMATION_TYPES } from 'ngx-loading';
imports:[
...
    LoadingModule.forRoot({
      animationType: ANIMATION_TYPES.wanderingCubes,
      backdropBackgroundColour: 'rgba(0,0,0,1)', 
      backdropBorderRadius: '4px',
      primaryColour: '#ffffff', 
      secondaryColour: '#ffffff', 
      tertiaryColour: '#ffffff'
  }),
...
]

在 app.component.ts 或您的 component.ts 中 //REQUIRE

loading: boolean = true; 

app.component.html 或您的 html 组件中

    <div class="my-container">
        <ngx-loading [show]="loading" [config]="{ 
                backdropBorderRadius: '14px', 
                backdropBackgroundColour: 'rgba(0,0,0,0.87)',
                fullScreenBackdrop: 'true',
                backdropBorderRadius: '10px',
                primaryColour: '#e2f000', 
                secondaryColour: '#e2f000', 
                tertiaryColour: '#e2f000'
             }">
        </ngx-loading>
    </div>

【讨论】:

    【解决方案4】:

    可能有点晚了,但我遇到了同样的问题。您需要在 app.module.ts 的导出数组中添加 LoadingModule:

    @NgModule({
     imports: [
    
    // loading spinner global settings
    LoadingModule.forRoot({
      animationType: ngxLoadingAnimationTypes.chasingDots,
      backdropBackgroundColour: 'rgba(0,0,0,0.4)',
      backdropBorderRadius: '4px',
      primaryColour: '#ffffff',
      secondaryColour: '#ffffff',
      tertiaryColour: '#ffffff',
      fullScreenBackdrop: true
     })
     ],
      declarations: [],
     entryComponents: [],
     exports: [ LoadingModule ]
    

    【讨论】:

      猜你喜欢
      相关资源
      最近更新 更多
      热门标签