Comments (9)
Yes indeed.
As @aitboudad indicated, here is the shared module you should have.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgLoadingBarModule } from 'ng-loading-bar';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule
],
exports: [
CommonModule,
FormsModule,
ReactiveFormsModule
]
})
export class SharedModule {
static forRoot() {
return [
{ngModule: SharedModule},
HttpModule,
NgLoadingBarModule.forRoot(),
];
}
}
Details:
If HttpModule or NgLoadingBarModule are in the exports or providers list in the shared module, a new corresponding instance would be provided by the child injector. The loading bar component wouldn't know about the new instance's 'pending' subject as it has only subscribed to the one provided by the root injector.
from ngx-loading-bar.
Thanks for the link, to fix you issue just ensure that NgLoadingBarModule
and HttpModule
is only part of root module.
export class SharedModule {
static forRoot(): any {
return [
{ ngModule: SharedModule },
HttpModule,
NgLoadingBarModule.forRoot(),
];
}
}
from ngx-loading-bar.
@Tolitech could you please provide a plunker reproducing the issue ?
from ngx-loading-bar.
Hello.
I created a very simple structure with root, shared, account...
In this small example, you can identify that the component only appears in the app.component and does not run on the other modules.
Note that the loading-bar-spinner div tag is always display: none with lazy loading modules.
Please export the project and run it locally.
Online is not running (there should be limitations in the online editor).
https://stackblitz.com/edit/angular-vkynnc
from ngx-loading-bar.
Hello,
I get a similar issue with the new alpha 3 :
If I access my app with the root URL and then navigate to a lazy loaded module, the loading bar is well displayed on each HttpClient call.
But if I then refresh my app being in my lazy loaded module (I press F5), I can't see the bar anymore.
It seems that the bar is well displayed only if I load app with the root URL.
Here is my shared module :
export class SharedModule {
static forRoot() {
return [
{ ngModule: SharedModule },
HttpClientModule,
LoadingBarHttpClientModule,
];
}
}
from ngx-loading-bar.
@spanja
The only way I was able to work with various lazy-loading modules and sharing modules was to put the HttpModule and ngx-loading-bar into the app.module.ts
Remove all references, imports, exports and declarations from anywhere, including the Shared Module.
Just leave it in the app.module that will work correctly.
from ngx-loading-bar.
I get same results with declaring LoadingBarHttpClientModule only in app module.
I'm using the new HttpClientModule instead of HttpModule
from ngx-loading-bar.
Sorry for the misunderstanding.
I have tested here and my code happens the same problem that you are facing.
A refresh by a route other than the main one, the loading-bar no longer appears.
Unfortunately I can not help you, just confirm that it is a possible bug in the component.
I think you should open a new issue for the creator.
from ngx-loading-bar.
I'm having the same thing with @spanja is the issue fixed?
from ngx-loading-bar.
Related Issues (20)
- NullInjectorError: StaticInjectorError(AppModule)[LoadingBarComponent -> LoadingBarService] HOT 1
- Angular 10 Support HOT 2
- Move tslint, typescript to devdeps
- Just saying thanks HOT 1
- @ngx-loading-bar/router - breaks in CLI 10.1.7 HOT 3
- ignoreLoadingBar in guard HOT 4
- ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'null'. Current value: '0'. HOT 2
- Only have loading bar when loading lazy module HOT 1
- Adding the <ngx-loading-bar> elsewhere than App.module and App.component.html HOT 1
- Loading bar breaks when combined with NGXS HOT 5
- NullInjectorError: No provider for e! - @ngx-loading-bar/http-client HOT 1
- Warning incorrect peer dependency HOT 1
- Not showing ngx-loading-bar for particular request
- Update to Angular 13 HOT 1
- add a demo HOT 2
- create mx-steps component to move between steps HOT 1
- Rendering issue on a configured bar in Webkit Browsers (not Safari) HOT 1
- Angular 14 support HOT 1
- Support for Angular 14 - throws an error ngcc compilation failed HOT 1
- Loading bar shows only after request is completed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-loading-bar.