Coder Social home page Coder Social logo

aitboudad / ngx-loading-bar Goto Github PK

View Code? Open in Web Editor NEW
758.0 17.0 82.0 4.4 MB

Automatic page loading / progress bar for Angular

Home Page: https://aitboudad.github.io/ngx-loading-bar

License: MIT License

JavaScript 5.57% TypeScript 89.32% SCSS 5.11%
angular loading-bar progress-bar

ngx-loading-bar's Introduction

@ngx-loading-bar


A fully automatic loading bar with zero configuration for Angular app (http, http-client and router).

Npm version Downloads Build Status


Packages

Demo

Table of contents

Getting started

1. Install @ngx-loading-bar:

  # if you use `@angular/common/http`
  npm install @ngx-loading-bar/core @ngx-loading-bar/http-client --save

  # if you use `@angular/router`
  npm install @ngx-loading-bar/core @ngx-loading-bar/router --save

  # to manage loading-bar manually
  npm install @ngx-loading-bar/core --save

Which Version to use?

Angular version @ngx-loading-bar/core
>=13.0 6.x
>=9.0 5.x
>=7.0 4.x

2. Import the installed libraries:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

// for HttpClient import:
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';

// for Router import:
import { LoadingBarRouterModule } from '@ngx-loading-bar/router';

// for Core import:
import { LoadingBarModule } from '@ngx-loading-bar/core';

import { AppComponent } from './app';

@NgModule({
  ...
  imports: [
    ...

    // for HttpClient use:
    LoadingBarHttpClientModule,

    // for Router use:
    LoadingBarRouterModule,

    // for Core use:
    LoadingBarModule
  ],
})
export class AppModule {}

Note: If using LoadingBarHttpClientModule with Angular Standalone APIs, ensure you import the providers from the module in the ApplicationConfig providers array:

import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';

export const appConfig: ApplicationConfig = {
  providers: [
    ...
    importProvidersFrom(LoadingBarHttpClientModule),
  ],
};

3. Include ngx-loading-bar in your app component:

import { Component } from '@angular/core';

@Component({
  selector: 'app',
  template: `
    ...
    <ngx-loading-bar></ngx-loading-bar>
  `,
})
export class AppComponent {}
Customize ngx-loading-bar

You can pass the following inputs to customize the view:

Input Description
color The color of loading bar. Default value is #29d.
includeSpinner Hide or show the Spinner. Default value is true.
includeBar Hide or show the Bar. Default value is true.
height The height of loading bar. Default value is 2px.
diameter The diameter of the progress spinner. Default value is 14px.
fixed set loading bar on the top of the screen or inside a container. Default value is true.
value Set the value of the progress bar.
ref Select the ref of a loading bar instance to display (http, router, ...)

Global config

The global config can be adjusted by providing a value for LOADING_BAR_CONFIG in your application's root module.

import { LOADING_BAR_CONFIG } from '@ngx-loading-bar/core';

@NgModule({
  providers: [
    providers: [{ provide: LOADING_BAR_CONFIG, useValue: { latencyThreshold: 100 } }],
  ]
})
Option Description
latencyThreshold The initial delay time to wait before displaying the loading bar. Default value is 0.

Ignoring particular requests

The loading bar can also be forced to ignore certain requests, for example, when long-polling or periodically sending debugging information back to the server.

http-client:

// ignore a particular $http GET:
httpClient.get('/status', {
  context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
});

router:

  • using the router.navigateByUrl() method:
this.router.navigateByUrl('/custom-path', {
  state: { ignoreLoadingBar: true },
});
  • using the routerLink directive:
<a routerLink="/custom-path" [state]="{ ignoreLoadingBar: true }">Go</a>

Manage multi loading bars separately

In some case you may want to differentiate the reason why the loading bar is showing for example show the loading bar when an HttpClient request is being made, and a full page darkening overlay with a spinner when the router is routing to a new page in that case either use ref input or LoadingBarService to control a specific loading bar instance:

  • using ref input:
<!-- loading bar for router -->
<ngx-loading-bar ref="router"></ngx-loading-bar>

<!-- loading bar for http -->
<ngx-loading-bar ref="http"></ngx-loading-bar>
  • using LoadingBarService service:
// select the router loader instance
const state = this.loader.useRef('router');

// control state
state.start();
state.complete();

// get the progress value
const value$ = state.value$;

Manually manage loading service

1. Import the LoadingBarModule

import { NgModule } from '@angular/core';

import { LoadingBarModule } from '@ngx-loading-bar/core';

@NgModule({
  ...
  imports: [
    ...

    LoadingBarModule,
  ],
})
export class AppModule {}

2. Inject/Use LoadingBarService

import { Component } from '@angular/core';
import { LoadingBarService } from '@ngx-loading-bar/core';

@Component({
  selector: 'app',
  template: `
    ...
    <ngx-loading-bar></ngx-loading-bar>
    <button (click)="loader.start()">start</button>
    <button (click)="loader.complete()">Complete</button>
  `,
})
export class App {
  loader = this.loadingBar.useRef();
  constructor(private loadingBar: LoadingBarService) {}
}

Integration with Material Progress bar

import { Component } from '@angular/core';
import { LoadingBarService } from '@ngx-loading-bar/core';

@Component({
  selector: 'app',
  template: `
    ...
    <mat-progress-bar mode="determinate" [value]="loader.value$ | async"></mat-progress-bar>
  `,
})
export class App {
  constructor(public loader: LoadingBarService) {}
}

Lazy Loading modules

If you're using Lazy Loaded Modules in your app, please use LoadingBarRouterModule, because although a request is being fired in the nework console to fetch your lazy load module.js file, it won't trigger the LoadingBarHttpClientModule.

Credits

ngx-loading-bar's People

Contributors

aitboudad avatar chihab avatar dependabot[bot] avatar gest01 avatar robvaneck avatar totati avatar vitale232 avatar ycintre avatar yusufugurozbek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-loading-bar's Issues

Customize color

It would be great if we can customize the color by passing the hex to the component to make it easier. :)

Loading bar doesn't fill all page width

I've tried three versions - httpclient, router and manual. And for all versions it works not like on your demo page. Loading bar starts to grow and stops at ~10-15% of width of the page. It can be for seconds in this position and then request finishes its work and loading bar is hiding. I've never seen loading bar reach full width.

Does someone have such behavior?

Loading bar doesn't trigger change detection

In our application the loading bar often gets "stuck" after a sequence of requests, it appears to make no progress whatsoever, but in fact the request has already been completed, the progress bar just hasn't updated. Clicking anywhere on the page triggers change detection which makes the progress bar disappear.

I noticed the progress bar component is using ChangeDetectionStrategy.OnPush, which according to the angular documentation means that component rendering depends only on its inputs. That doesn't seem to be the case here since the progress variable is retrieved directly from the service rather than being set as an input?

Infinitive loading

After some requests the loading bar do not disappear after request is finished.

I have the version: "@ngx-loading-bar/http": "^1.0.0-rc.3",

Ionic 3 and lazy loading configuraiton example

First thank you for this quit up-to-date module. I am trying to make this module work with Ionic 3 (which uses Angular 4.1.3 at the moment, Note: Angular 4.3.x support will come in next release) plus it's lazy loading setup. but It seems I have to import LoadingBarModule in both modules(root and lazy loaded one) and after that LoadingBarService doesn't work as expect when is called from lazy-loaded pages. Note: 'ngx-loading-bar' is not a known element error will throw if lazy-loaded module doesn't import LoadingBarModule.

Under this issue title, it will be great if someone can provide a working example for Ionic 3 and lazy loading configuration.

Thanks!
p.s. If you have any suggestions? I will be happy to try it and see if works or not.

Provide a way to cancel/abort the ongoing ajax requests while showing a loading

It would be nice and can be a great to have feature if we could add a support having a close button to cancel/abort ongoing XHR requests which will come in handy for requests which will take quite some time to load the response.

For example user want to load a historical data report for last 5 years or something which might take more time to process and return back the response and users might want to cancel that request since its taking too long.
Also we can think of many such use cases where user want to abort the requests and navigate to other view.

Hope it makes sense.

Thanks,
Bhasker

custom _latencyThreshold?

Is there a reasonable way to alter _latencyThreshold? Would be nice to be able to configure it, thanks!

Upgrade to Rxjs 6

Hello,

It is possible to upgrade to latest Rxjs in order to be compatible with Angular 6 ?

Regards

Progress bar does not show when an HTTP request is made

Loading bar shows on router change but not when an HTTP request is made. I am using HttpClientModule from @angular/common/http.
"dependencies": { "@angular/animations": "^5.2.0", "@angular/common": "^5.2.0", "@angular/compiler": "^5.2.0", "@angular/core": "^5.2.0", "@angular/forms": "^5.2.0", "@angular/http": "^5.2.0", "@angular/platform-browser": "^5.2.0", "@angular/platform-browser-dynamic": "^5.2.0", "@angular/router": "^5.2.0", "@ngx-loading-bar/core": "^1.1.1", "@ngx-loading-bar/http": "^1.1.1", "@ngx-loading-bar/http-client": "^1.1.1", "@ngx-loading-bar/router": "^1.1.1", "core-js": "^2.4.1", "jquery": "^1.11.1", "ngx-pagination": "^3.0.3", "rxjs": "^5.5.6", "zone.js": "^0.8.19" },

doesn't show loading bar when submitting form

Hi. ngx-loading-bar does not show loading bar on submitting a form or sending data to backend.

My AppModule:

@NgModule({
    bootstrap: [AppComponent],
    declarations: [AppComponent],
    imports: [
        
        CommonModule,
        FormsModule, 
        RouterModule,
     
        BrowserAnimationsModule,

        LoadingBarHttpClientModule,
        LoadingBarHttpModule, 
        LoadingBarRouterModule,
        LoadingBarHttpClientModule, 
        //LoadingBarHttpClientModule.forRoot(),
        AppRoute,
    ],
    providers: [
 
    ],
    exports: []
})

Loading bar appears only on changing routes.

@ngx-loading-bar 1.1.0 throws error "XMLHttpRequest is not defined" on plattform-server

I updated ngx-loading-bar to latest version. unfortunately, on plattform-server (universal production build) I get following error:
ReferenceError: XMLHttpRequest is not defined at BrowserXhr.build …

Even when checking if platform is browser <ngx-loading-bar *ngIf="isPlatformBrowser"></ngx-loading-bar>(to prevent rendering of loading bar on server-side) I get the error.

Angular Version 5.2.0

Remove tight coupling with Http api

Loading should be an activity on its own.

Currently, this is tightly coupled with Http Api, because of which the number of usecases this component can be used is limited.

Instead, the API should be open for any scenario, such as during route change/some other progress user have complete control over.

If the user wants to use this in lets say for showing & hiding during an http request, they should use library like ng2-interceptors or x-ng2-http-interceptor (I wrote this)

Once you separate this component from Http, the scope of usage for this component will go up.

Also, the page flickers like crazy in the demo, which is an indication that there is an issue with the way you are using timers in the library

Use with system js

OS and Version?

Windows 10.

Versions

Node: v8.10.0
Npm: 5.7.1
Angular: 5.2.9

Question

How do I use the loading bar with system.js?
Do I need to import the librarty into system.config.js file?
And if so, how?

Thank you.

Loading Bar doesn't show

Hey,

thanks for your package.

Unfortunately, it doesn't work in our proejct.

I dug into the code and I cannot find out why. It seems progress.started is never true. Also I found that the _pendingRequests counter gets emitted as 0 and then, afterwards, the LoadingBarComponent subscribes to the http.pending event. Why is that? Might this be the cause of the problem?

We are using a multi-module setup with one module that acts as a root module (AppModule) and a SharedModule that each module imports.

Overall, this is very frustrating since there is absolutely no package doing what your package does.

ngx-loading-bar break unsuscribe

When using ngx-loading-bar on '@angular/http';.

The request cancel on Obervable unsuscribe does not work.

this.getProducts
   .subscribe((products) => {
        ....
   })
   .unsuscribe();      // Does not cancel request when using ngx-loading-bar  !!!!!

Have you an idea about this problem ?

[doc] add Support for Hybrid Angular/AngularJS apps

  1. downgrade LoadingBarService:
import { LoadingBarService } from '@ngx-loading-bar/core';
ng1AppModule.factory('loadingBarService', downgradeInjectable(LoadingBarService));
  1. create custom HttpInterceptor
$provide.factory('loadingBarHttpInterceptor', function (loadingBarService) {
  return {
    'request': function (config) {
      loadingBarService.start();
      ...
    },

    'requestError': function (rejection) {
      loadingBarService.complete();
      ...
    },

    'response': function (response) {
      loadingBarService.complete();
      ...
    },

    'responseError': function (rejection) {
      loadingBarService.complete();
      ...
    }
  };
});

Loading bar http client not working with async interceptor

Hello,

I have updated my interceptor to get my token async, but now the loading bar is not displayed on request.

My project works on Angular 5 latest version.

This is my interceptor, can you help me ?

  intercept(req: HttpRequest<any>, next: HttpHandler) {
    console.log('interceptor called');
    if (!req.headers.has('Content-Type')) {
      req = req.clone({ headers: req.headers.set('Content-Type', 'application/json') });
    }

    req = req.clone({ setHeaders: {Accept: 'application/json', 'X-Requested-With': 'XMLHttpRequest'} });

    return Observable.fromPromise(this.addToken(req, next));
  }

  private async addToken(req: HttpRequest<any>, next: HttpHandler): Promise<HttpEvent<any>>  {
    const user: User = await this.fAuth.auth.currentUser;

    if (user != null) {
      await user.getIdToken().then(token => {
        req = req.clone({ setHeaders: {Authorization: token} });
      });

    }

    return next.handle(req).toPromise();
  }

Custom loading template

Is there any plan for providing a way to specify a custom template?

Example from the AngularJs version (https://github.com/chieffancypants/angular-loading-bar)

Customize the template:
If you'd like to replace the default HTML template you can configure it by providing inline HTML as a string:

angular.module('myApp', ['angular-loading-bar'])
  .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
    cfpLoadingBarProvider.spinnerTemplate = '<div><span class="fa fa-spinner">Loading...</div>';
  }])

It would be very nice to have that option, thanks.

Disable the loading bar for certain HTTP requests

The package angular-loading-bar which is similar but for Angular 1.x has an option that can be injected into the $http request options that allow us to turn off the loading bar, does it support it? If not, it would be nice and useful to have it :)

this.$http
      .get(`${config.API_URL}${url}`, {
        ignoreLoadingBar: true,
      }).then(() => {

Thanks!

Not an issue but just wanted to leave a note saying good job. I was hunting for an automatic solution and was about to roll my own when I stumbled across this repo. Thanks!

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '[object Object]'. Current value: '2'.

Sometimes I catching an exception:

LoadingBarComponent.html:2 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '[object Object]'. Current value: '2'.
    at viewDebugError (core.es5.js:8433)
    at expressionChangedAfterItHasBeenCheckedError (core.es5.js:8411)
    at checkBindingNoChanges (core.es5.js:8575)
    at checkNoChangesNodeInline (core.es5.js:12416)
    at checkNoChangesNode (core.es5.js:12390)
    at debugCheckNoChangesNode (core.es5.js:13183)
    at debugCheckDirectivesFn (core.es5.js:13085)
    at Object.eval [as updateDirectives] (LoadingBarComponent.html:2)
    at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13067)
    at checkNoChangesView (core.es5.js:12230)

  | View_LoadingBarComponent_0 | @ | LoadingBarComponent.html:2
-- | -- | -- | --
  | proxyClass | @ | compiler.es5.js:14985
  | webpackJsonp.../../../core/@angular/core.es5.js.DebugContext_.logError | @ | core.es5.js:13407
  | webpackJsonp.../../../core/@angular/core.es5.js.ErrorHandler.handleError | @ | core.es5.js:1080
  | (anonymous) | @ | core.es5.js:4819
  | webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke | @ | zone.js:392
  | webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run | @ | zone.js:142
  | webpackJsonp.../../../core/@angular/core.es5.js.NgZone.runOutsideAngular | @ | core.es5.js:3844
  | webpackJsonp.../../../core/@angular/core.es5.js.ApplicationRef_.tick | @ | core.es5.js:4819
  | (anonymous) | @ | core.es5.js:4684
  | webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke | @ | zone.js:392
  | onInvoke | @ | core.es5.js:3890
  | webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke | @ | zone.js:391
  | webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run | @ | zone.js:142
  | webpackJsonp.../../../core/@angular/core.es5.js.NgZone.run | @ | core.es5.js:3821
  | next | @ | core.es5.js:4684
  | schedulerFn | @ | core.es5.js:3635
  | webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.__tryOrUnsub | @ | Subscriber.js:239
  | webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.next | @ | Subscriber.js:186
  | webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber._next | @ | Subscriber.js:127
  | webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber.next | @ | Subscriber.js:91
  | webpackJsonp.../../../../rxjs/_esm5/Subject.js.Subject.next | @ | Subject.js:56
  | webpackJsonp.../../../core/@angular/core.es5.js.EventEmitter.emit | @ | core.es5.js:3621
  | checkStable | @ | core.es5.js:3855
  | onLeave | @ | core.es5.js:3934
  | onInvokeTask | @ | core.es5.js:3884
  | webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:424
  | webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask | @ | zone.js:192
  | webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask | @ | zone.js:499
  | invokeTask | @ | zone.js:1540
  | globalZoneAwareCallback | @ | zone.js:1566

My code

[package.json]
...
"dependencies": {
...
  "@ngx-loading-bar/http": "^1.0.0-alpha.16",
...
[app/app.module.ts]
// node_modules
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {NgModule} from '@angular/core';
import {HttpModule} from '@angular/http';
import {Routes, RouterModule} from '@angular/router';
import {NgbModalModule} from '@ng-bootstrap/ng-bootstrap';
import { LoadingBarHttpModule } from '@ngx-loading-bar/http';
// AppComponent
import {AppComponent} from './app.component';

// Core
import {CoreModule} from './core/core.module';

// Features
import {LoginModule, ActivationModule, MainModule} from './features';

// Setup routes
const appRoutes: Routes = [
    {path: '**', redirectTo: '/'},
];

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        HttpModule,
        LoadingBarHttpModule,
        RouterModule.forRoot(appRoutes),
        NgbModalModule.forRoot(),
        CoreModule,
        LoginModule,
        ActivationModule,
        MainModule
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
}
[app/app.component.html]
<ngx-loading-bar></ngx-loading-bar>
<router-outlet></router-outlet>

Aysnc

If you have to use this in your template that uses async, just teminate it by calling finally on the Observable of the async.

Thanks

Set initial value of progress

I would like to be able to set the initial value for the progress bar, which is currently hardcoded to 2%. Most of the time I set its initial value to 10 so there's more visibility when a request is made.

Maybe making the "set" function public could be done, so that it could be set to any value at any time.

not working on latest angular @ 5.2.2

Hi i am re creating this issue i confirmed by creating new project and adding it loading bar
my latest packege.json dependencies are here:

"dependencies": {
"@ angular/animations": "^5.2.2",
"@ angular/cdk": "^5.1.0",
"@ angular/common": "^5.2.2",
"@ angular/compiler": "^5.2.2",
"@ angular/core": "^5.2.2",
"@ angular/flex-layout": "^2.0.0-beta.12",
"@ angular/forms": "^5.2.2",
"@ angular/http": "^5.2.2",
"@ angular/material": "^5.1.0",
"@ angular/platform-browser": "^5.2.2",
"@ angular/platform-browser-dynamic": "^5.2.2",
"@ angular/router": "^5.2.2",
"@ ngx-loading-bar/http-client": "^1.1.0",

"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"

},

Adding a new service to manage loading/progress bar manually

I think we also need a service which handles showing loading/progress bar manually in some other common use cases too which are asynchronous in nature but may not necessarily be the XHR requests which is what this project is currently aimed at to provide a solution for.

I think it wouldn't be a complete solution until we have a full control on showing and hiding a loading bar even manually in some usecases such as using setTimeOuts, reading data from the offline browser storage, page transitions etc;

Thanks,
Bhasker

Bar doesn't progress if there are http calls before ngx-loading-bar is loaded

Hello,
I get a similar issue as #14 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,
    ];
  }
}

I get same results with declaring LoadingBarHttpClientModule only in app module.

I'm using the new HttpClientModule instead of HttpModule

Error Start Projet

  • node version = 8.9.1
  • npm version = 5.5.1

Something wrong when compile libraries, cuz after run command "npm start" i get this error :

1 npm start 28open 29 2018-02-28 15-23-58

Position of loading bar

Any way to position the loading bar inside of a div instead of at the top of the page? I tried in CSS:

ngx-loading-bar {
    position: absolute;
}

.parentelement {
    position: relative;
}

My template looks like:

<div class="parentelement">
    <ngx-loading-bar></ngx-loading-bar>
</div>

When I inspect the element in the browser I can see that it does have the correct styling from the stylesheet, but it continues to stay at the top of the page (where it works fine otherwise).

Anything I'm missing? Thanks.

Documentation for ignoreLoadingBar

Can see the implementation in the source code but cannot figure out how to use it with Http-Client and passing of metadata. Would be nice with some documentation and usage example for the feature. Thanks.

Error when run ng serve

I a'm using angula-cli for run and development my app (https://github.com/angular/angular-cli)

When i run ng serve (run liveReload server in development mode) i get an error

Uncaught TypeError: ctorParameters.map is not a function
at ReflectionCapabilities.parameters (http://localhost:4200/main.bundle.js:48161:45)
at Reflector.parameters (http://localhost:4200/main.bundle.js:48295:44)
at CompileMetadataResolver.getDependenciesMetadata (http://localhost:4200/main.bundle.js:27527:54)
at CompileMetadataResolver.getTypeMetadata (http://localhost:4200/main.bundle.js:27492:26)
at CompileMetadataResolver.getDirectiveMetadata (http://localhost:4200/main.bundle.js:27267:28)
at http://localhost:4200/main.bundle.js:27336:49
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:4200/main.bundle.js:27329:44)
at http://localhost:4200/main.bundle.js:27317:50
at Array.forEach (native)

In production mode the error no

Does not seem to fire when http request made....

the component renders in the html dom i can see it if i open the html, however when http requests are running it does not go from display:none to visible. I assume it is not firing or picking up http.

Could this be because i am using my own Http Interceptor (i am using token authentication and need to have my own interceptor)

In my app module i am doing:

 providers: [
    {

      provide: Http,
      useFactory: httpFactory, //(xhrBackend: XHRBackend, requestOptions: RequestOptions, appSettings: AppSettings, nav) => new HttpInterceptor(xhrBackend, requestOptions, appSettings, nav),
      deps: [XHRBackend, RequestOptions, AppSettings],

    },

And

export function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions, appSettings: AppSettings) {
  return new HttpInterceptor(xhrBackend, requestOptions, appSettings);
}

With HttpInterceptor being my own interceptor.... is this somehow messing with your code?

HTTP queries are executed twice

Without ngx-loading-bar, all HTTP requests done with Angular's http service are executed once.
With ngx-loading-bar, all HTTP requests done with Angular's http service are executed twice.

bug

Modules with lazy loading.

Hello.
In my project I have multiple modules with lazy loading, however, the component only displays the "progress indicator" when the services are part of the root module.

While in another module, the "progress bar" is never displayed.
It only appears in other modules when I put the tag on every page html.

That is, putting the tag in the app.component.html only works for some services, being that for services created in the modules, I have to put in all the html pages.

Is there any way to get around this and just keep the tag in app.component.html?

thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.