Git Product home page Git Product logo

ngx-spinner's Introduction

A library with more than 50 different loading spinners for Angular 4 - 17. (https://napster2210.github.io/ngx-spinner/)

NgxSpinner

Support Support Support Support Support Support Support Support Support Support Support Support Support Support License Gitter

What's New

  • Angular 17 support ๐Ÿฅณ๐Ÿฅณ๐Ÿฅณ๐Ÿฅณ

Use appropriate version based on your Angular version.

Angular 17 Angular 16 Angular 15
>=v17.0.0 >=v16.0.2 >=v15.0.1
Angular 14 Angular 13 Angular 12 Angular 11 Angular 10
>=v14.0.0 >=v13.1.1 >=v12.0.0 >=v11.0.2 >=v10.0.1
Angular 9 Angular 8 Angular 6/7 Angular 5 Angular 4
>=v9.0.1 v8.1.0 v7.2.0 >=v1.2.0 >=v2.0.0

Table of contents

Browser Support

Chrome
Chrome
Firefox
Firefox
IE / Edge
IE / Edge
iOS Safari
Safari
Opera
Opera
Latest โœ” Latest โœ” IE11, Edge โœ” Latest โœ” Latest โœ”

Features

  • Angular 17 Support
  • Custom spinner image support(gif), you can pass img tag
  • Multiple Spinners
  • Configurable option through service
  • Fullscreen Mode(Enable/Disable)
  • show()/hide() methods return promise
  • Dynamic z-index
  • Smooth animation while hide/show the spinner
  • New updated DEMO website
  • Option to disable fade animation
  • Show/Hide spinner from template using @Input() variable
  • Smaller bundle size

Demo

Working Demo

StackBlitz Demo

Installation

ngx-spinner is available via npm and yarn

Using npm:

$ npm install ngx-spinner --save

Using yarn:

$ yarn add ngx-spinner

Using angular-cli:

$ ng add ngx-spinner

Usage

Add css animation files to angular.json config

{
  "styles": [
    "node_modules/ngx-spinner/animations/ball-scale-multiple.css" // ===> Add css file based on your animation name(here it's "ball-scale-multiple")
    // You're able to add multiple files if you need
  ]
}

Import NgxSpinnerModule in in the root module(AppModule):

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
// Import library module
import { NgxSpinnerModule } from "ngx-spinner";

@NgModule({
  imports: [
    // ...
    BrowserAnimationsModule,
    NgxSpinnerModule,
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}

NOTE

  • There is possibility to use global configuration for NgxSpinnerModule.
  • Just call forRoot method for NgxSpinnerModule and pass configuration object.
  • The input properties of NgxSpinnerComponent has higher priority than global options
// Available options
interface NgxSpinnerConfig {
  type?: string;
}
// Use in app
@NgModule({
  imports: [
    NgxSpinnerModule.forRoot({ type: 'ball-scale-multiple' })
  ]
})

Add NgxSpinnerService service wherever you want to use the ngx-spinner.

import { NgxSpinnerService } from "ngx-spinner";

class AppComponent implements OnInit {
  constructor(private spinner: NgxSpinnerService) {}

  ngOnInit() {
    /** spinner starts on init */
    this.spinner.show();

    setTimeout(() => {
      /** spinner ends after 5 seconds */
      this.spinner.hide();
    }, 5000);
  }
}

Now use in your template

<ngx-spinner type="ball-scale-multiple"></ngx-spinner>

See Demo

Methods

  • NgxSpinnerService.show() Shows the spinner
  • NgxSpinnerService.hide() Hides the spinner

Available Options

  • [bdColor]: RGBA color format. To set background-color for backdrop, default rgba(51,51,51,0.8) where alpha value(0.8) is opacity of backdrop
  • [size]: Anyone from small, default, medium, large. To set size of spinner, default large
  • [color]: Any css color format. To set color of spinner, default #fff
  • [type]: Choose any animation spinner from Load Awesome. To set type of spinner
  • [fullScreen]: true or false To enable/disable fullscreen mode(overlay), default true
  • [name]: For multiple spinners To set name for spinner, default primary
  • [zIndex]: For dynamic z-index To set z-index for the spinner, default 99999
  • [template]: For custom spinner image To set custom template for the custom spinner, default null
  • [showSpinner]: true or false To show/hide spinner from template using variable
  • [disableAnimation]: true or false To enable/disable fade animation of spinner, default false

Using Spinner Type

<ngx-spinner
  bdColor="rgba(51,51,51,0.8)"
  size="medium"
  color="#fff"
  type="ball-scale-multiple"
>
  <p style="font-size: 20px; color: white">Loading...</p>
</ngx-spinner>

Using Custom Spinner

<ngx-spinner
  bdColor="rgba(0, 0, 0, 1)"
  template="<img src='https://media.giphy.com/media/o8igknyuKs6aY/giphy.gif' />"
>
</ngx-spinner>

NOTE

  • You can pass HTML code as loading text now, instead of input parameter(loadingText). Check above code for reference.
  • If you want multiple ngx-spinner instance, just add name attribute with ngx-spinner component. But in this case, you've to pass that particular name of a spinner in show/hide method. Check Demo
  • You can also change the options/configuration of spinner through service now.
  • For smaller bundle size, add specific css file under "styles" array in angular.json file
this.spinner.show("mySpinner", {
  type: "line-scale-party",
  size: "large",
  bdColor: "rgba(0, 0, 0, 1)",
  color: "white",
  template:
    "<img src='https://media.giphy.com/media/o8igknyuKs6aY/giphy.gif' />",
});

How to use type?

  • Go to the Load Awesome.
  • Select any animation, copy name of animation, replace all spaces with hyphen(-) and all letters should be lowercase.
    • Let's say if I select "Ball 8bits" animation then type will be ball-8bits.
    • For more information you can check it out Demo
    • For smaller bundle size you need to add css for ball-8bits animation(e.g. ball-8bits.css)

Useful Tips

  • Make sure you've added CUSTOM_ELEMENTS_SCHEMA as your schema in your main module.
  • If you use multiple show() methods in a single component or single function one after another then wrap the show() method within setTimeout() method to avoid any rendering issue.
  • When you want to use spinner inside any container(fullScreen: false), in that case your parent element of spinner must have position: relative; style property.
  • You can't set custom template through service options, it's a limitation by Angular itself.

Versioning

ngx-spinner will be maintained under the Semantic Versioning guidelines. Releases will be numbered with the following format:

<major>.<minor>.<patch>

For more information on SemVer, please visit http://semver.org.

Creator

Future Plan

  • Interceptor Implementation

Ask Me

  • Now you can directly send me a message on Gitter for any query/suggestion/updates

Credits

Inspired by Load Awesome by Daniel Cardoso.

Thanks Alex Vieira Alencar for helping me with Multiple Spinner Support.

Thanks ennjin for reducing the bundle size.

License

ngx-spinner is MIT licensed.

ngx-spinner's People

Contributors

dependabot[bot] avatar frsimond avatar napster2210 avatar napster41 avatar rspl-yuvraj 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  avatar  avatar  avatar

ngx-spinner's Issues

Use as loader

Hi,

Is it possible to use this as a loader for a specific section of my page (e.g table loading) and not the entire page which blocks?

Thanks

Spinner with Indeterminate time

I did not find a way to use the ngx-spinner for indeterminate time. API response time, in development env, is unpredicatable and I need a way for the spinner to stop immediately after receiving the response. Please suggest.

Size of ngx-spinner in bundle

In my current project I determined the size of the libraries used in the delivery package. (Build with angular cli 6.0.x -> ng build --prod)

I realized that ngx-spinner has a size of 454.6 KB (ngx-spinner.ngfactory.js.pre-build-optimizer.js: 240.63 KB, ngx-spinner.umd.js_ 212.62 KB)

This seems really big.
So my question: is this stuff really needed for delivering?

customize loading text

how to customize loading text as using multiple lines with different classes and tags of HTML and using icons
example:
loadingText:"loading"
I want to write multiple lines with different classes and tags of HTML as:
< h1 >loading ...< h1 >
< span > please wait < br/ > .......</ span >

Dependency error when installing on Angular 5.2.9

Hello,

The ngx-spinner version 1.1.0 should work on Angular 5.2.9 ?

$>npm install ngx-spinner@latest --save
npm WARN [email protected] requires a peer of @angular/core@^4.0.0 but none is installed. You must install peer dependencies yourself.

"dependencies": {
"@angular/animations": "^5.2.9",
"@angular/common": "^5.2.9",
"@angular/compiler": "^5.2.9",
"@angular/core": "^5.2.9",
...

Tks!
Jorge

Use an image for spinner

Hi, Like as enhancement, will be great if we can add a custom gif image or icon to use for spinner.

Unable to change opacity of inner elements

Can you move the opacity setting to another element? The way the template is structured currently prevents the ability to fully override the default styling. The parent container forces inheritance of the opacity, and there isn't a way to change that with CSS alone.

Ignore loading Bar in some backend calls

Need a new feature to ignore loading bar in some request, where response time is too less.

Real case scenario : we make lookup service call to backed for drop downs, so when we edit a letter it again call the service an at times, response is quite fast this creates flashy screen and user experience is not ver good

Expression based show/hide instead of service based?

Is it possible now, or in a future update, to have the ability to show/hide the spinner based on an expression evaluation instead of having to use the service?

Something like

pendingLoads: number = 0;
<ngx-spinner [show]="pendingLoads > 0">

So if it evals to true, then show otherwise hide.

Thanks
-Ray

Spinner Message

A message will be a nice optional parameter to display below the spinner. e.g. Loding...

Using into http interceptors

Hi there,
I don't know how to use it with interceptor.
Spinner never appears.

app.module.ts

import { NgxSpinnerModule } from 'ngx-spinner';

imports: [
    ...
    NgxSpinnerModule,
    ...
]

interceptor.ts

import { NgxSpinnerService } from 'ngx-spinner';
export class LoadingInterceptor implements HttpInterceptor {
constructor(private spinner: NgxSpinnerService) { }

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        /** spinner starts on init */
        this.spinner.show();
        return next.handle(req).do((event: HttpEvent<any>) => {
            /** spinner ends */
            this.spinner.hide();
        }, (err: any) => {
            /** spinner ends */
            this.spinner.hide();
        });        
    }

app.html:

<ion-nav [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
<ngx-spinner></ngx-spinner>

Default visibility

Currently the spinner is disabled by default.
You have to call .show() action to show it.
But, in some cases, the service injection is too long and i want to show the spinner during this loading time.

Add an optional attribute to set the default visibility (at false by default).

Exemple

<ngx-spinner bdColor="rgba(51, 51, 51, 0.8)" size="large" color="#fff" type="square-loader" loadingText="Loading app..." isVisibleByDefault="true"></ngx-spinner> ```

[Feature Request] Dynamic Loading Text

I would like to know if it's possible to implement a feature where I can set the spinner text dynamically, for example:

component.html

<ngx-spinner
  bdColor="rgba(51,51,51,0.8)"
  size="medium"
  color="#fff"
  type="ball-scale-multiple">
 <p style="font-size: 20px; color: white">{{ text }}</p>
</ngx-spinner>

component.ts

this.spinner.show({ text: "Loading Profile Info..." })

Spinner goes up on scroll

hi,

i am trying to use the spinner service in my app. now what i have seen is that loader is full screen at first view but as the view scrolls down the spinner is stuck above it does not remains fix at on place.

the thing i say was the black-overlay class where position is set zero but as i make is fixed from chrome console it remains there as i scroll down.

can you help me out with this? how can i override your class position?

npm i ngx-spinner not working

npm i ngx-spinner
npm ERR! Unexpected token < in JSON at position 14274

Here are the logs:
verbose stack SyntaxError: Unexpected token < in JSON at position 14274
13 verbose stack at JSON.parse ()
13 verbose stack at module.exports (C:\Program Files\nodejs\node_modules\npm\lib\utils\parse-json.js:3:15)
13 verbose stack at BB.join (C:\Program Files\nodejs\node_modules\npm\lib\install\read-shrinkwrap.js:31:20)
13 verbose stack at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
13 verbose stack at Holder$3._callFunction (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), :14:44)
13 verbose stack at Holder$3.checkFulfillment (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), :29:30)
13 verbose stack at Promise.eval (eval at thenCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:14:16), :6:20)
13 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
13 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
13 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
13 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
13 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:582:21)
13 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
13 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
13 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
13 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21
14 verbose cwd C:\Users\Z003U7UJ\git\galaxy4.0\galaxyApp
15 verbose Windows_NT 6.1.7601
16 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i" "[email protected]"
17 verbose node v8.9.4
18 verbose npm v5.6.0
19 error Unexpected token < in JSON at position 14274
20 verbose exit [ 1, true ]

waring in defineInjectable

WARNING in ./node_modules/ngx-spinner/fesm5/ngx-spinner.js
69:59-75 "export 'defineInjectable' was not found in '@angular/core'
at HarmonyImportSpecifierDependency._getErrors

Found version 4, expected 3, resolving symbol AppModule

Hi,

I am using Angular 4 and i am getting the following error:
node_modules/ngx-spinner/ngx-spinner.d.ts, found version 4, expected 3, resolving symbol AppModule

I downgraded to all versions but I still get the same error.

Thanks

Feature Request: Only cover certain element

It'd be great if there were a way to set the ngx-spinner to only cover a table that's loading for instance, rather than the whole page. If there isn't a way to do this now, could this please be added in the future?Thanks,

David

i0.defineInjectable is not a function

I have a problem with spinner I have downloaded the package and implemented as shown below. But I get an error any help please.

Thanks.

image

In Module
import { NgxSpinnerModule } from 'ngx-spinner';

// ........

@NgModule({
// ...
  imports: [
  NgxSpinnerModule
]
})

In Component
import { NgxSpinnerService } from 'ngx-spinner';

package.json

"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/compiler-cli": "^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/platform-server": "^5.2.0",
"@angular/router": "^5.2.0",
"@toverux/ngx-sweetalert2": "^4.0.0",
"angular-imask": "1.0.2",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"imask": "^4.0.0",
"jquery": "3.1.1",
"ngx-currency": "^1.5.0",
"ngx-spinner": "^6.1.2",
"perfect-scrollbar": "^1.4.0",
"rimraf": "^2.6.2",
"rxjs": "^5.5.11",
"rxjs-es": "^5.0.0-beta.12",
"rxjs-system-bundle": "^5.1.1-2",
"sweetalert2": "^7.26.23",
"systemjs": "^0.20.9",
"tiny-date-picker": "^3.2.6",
"tippy.js": "^3.0.4",
"zone.js": "^0.7.7"
},

'ngx-spinner' is not a known element

When runtime, my app throw this message at console :
'ngx-spinner' is not a known element:

  1. If 'ngx-spinner' is an Angular component, then verify that it is part of this module.
  2. If 'ngx-spinner' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("


    [ERROR ->]<ngx-spinner bdColor = "rgba(51, 51, 51, 0.8)" size = "medium" color = "#fff" type = "ball-clip-rotat"): ng:///DetailCustomerModule/DetailRepresentativeComponent.html@209:8
    at syntaxError (compiler.js:485)
    at TemplateParser.parse (compiler.js:24668)
    at JitCompiler._parseTemplate (compiler.js:34621)
    at JitCompiler._compileTemplate (compiler.js:34596)
    at eval (compiler.js:34497)
    at Set.forEach ()
    at JitCompiler._compileComponents (compiler.js:34497)
    at eval (compiler.js:34367)
    at Object.then (compiler.js:474)
    at JitCompiler._compileModuleAndComponents (compiler.js:34366)
    at syntaxError (compiler.js:485)
    at TemplateParser.parse (compiler.js:24668)
    at JitCompiler._parseTemplate (compiler.js:34621)
    at JitCompiler._compileTemplate (compiler.js:34596)
    at eval (compiler.js:34497)
    at Set.forEach ()
    at JitCompiler._compileComponents (compiler.js:34497)
    at eval (compiler.js:34367)
    at Object.then (compiler.js:474)
    at JitCompiler._compileModuleAndComponents (compiler.js:34366)
    at resolvePromise (zone.js:809)
    at resolvePromise (zone.js:775)
    at eval (zone.js:858)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4740)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)
    at ZoneTask.invokeTask [as invoke] (zone.js:500)
    at invokeTask (zone.js:1517)

Can do you support me
Thanks !

Help needed, SyntaxError: Unexpected token <

Hi, I must be missing out on something for this issue to be caused.
Using Angular 4

I get the following Error in Console when I import your NgxSpinnerModule from ngx-spinner in app.module

(index):17 Error: (SystemJS) Unexpected token <
	SyntaxError: Unexpected token <
	    at eval (<anonymous>)
	    at Object.eval (http://localhost:57028/app/app.module.js:21:21)
	    at eval (http://localhost:57028/app/app.module.js:38:4)
	    at eval (http://localhost:57028/app/app.module.js:39:3)
	Evaluating http://localhost:57028/ngx-spinner
	Evaluating http://localhost:57028/app/app.module.js
	Evaluating http://localhost:57028/app/main.js
	Error loading http://localhost:57028/app/main.js
	    at eval (<anonymous>)
	    at Object.eval (http://localhost:57028/app/app.module.js:21:21)
	    at eval (http://localhost:57028/app/app.module.js:38:4)
	    at eval (http://localhost:57028/app/app.module.js:39:3)
	Evaluating http://localhost:57028/ngx-spinner
	Evaluating http://localhost:57028/app/app.module.js
	Evaluating http://localhost:57028/app/main.js
	Error loading http://localhost:57028/app/main.js

This is my app.module

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
import { HomeComponent } from './components/home.component';
import { UserService } from './Service/user.service';
import { UserComponent } from './Components/user.component';
import { SearchComponent } from './Components/search.component';
import { FormsModule } from '@angular/forms';
import { NgxSpinnerModule } from 'ngx-spinner';


@NgModule({
    imports: [BrowserModule, ReactiveFormsModule, FormsModule, HttpModule, NgxSpinnerModule, routing],
    declarations: [AppComponent, UserComponent, HomeComponent, SearchComponent],
    providers: [{ provide: APP_BASE_HREF, useValue: '/' }, UserService],
    bootstrap: [AppComponent],
    schemas: [CUSTOM_ELEMENTS_SCHEMA]
})

export class AppModule { }

This is my package.json

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~4.3.4",
    "@angular/compiler": "~4.3.4",
    "@angular/core": "~4.3.4",
    "@angular/forms": "~4.3.4",
    "@angular/http": "~4.3.4",
    "@angular/platform-browser": "~4.3.4",
    "@angular/platform-browser-dynamic": "~4.3.4",
    "@angular/router": "~4.3.4",
    "angular-in-memory-web-api": "~0.3.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.4",
    "ngx-spinner": "1.2.0"
  },
  "devDependencies": {
    "@angular/cli": "^6.1.5",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.2.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.1.0"
  },
  "repository": {}
}

And systemjs.config.js
I think the problem might lie in this file. Is there any declaration missing in systemjs.congfig.js ?

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: '/app',

            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs': 'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
            'ng2-bs3-modal': 'npm:/ng2-bs3-modal'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: 'main.js', defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            }
            ,
            'ng2-bs3-modal':
            { main: '/bundles/ng2-bs3-modal.js', defaultExtension: 'js' }
        }
    });
})(this);

and tsconfig.json if that is of any use

{
  "compilerOptions": {
    "noStrictGenericChecks": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

I have not yet called the tag in the HTML, as the error fires from app.module.ts.
Any help will be very much appreciated, I looked over the web for similar issues but to no avail.
Thanks !

spinner not working in IE. and am using angular 6

ngx-spinner is a custom element, so in this case, if you add <ngx-spinner> in your HTML file then you have to add CUSTOM_ELEMENTS_SCHEMA to your app module.

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

// ........

@NgModule({
// ...
  schemas: [
    CUSTOM_ELEMENTS_SCHEMA
]
})

Changing style after first use

Hi!

I want to use the spinner (ngx-spinner v6.1.2 - see) on a custom style on the first loading (loading my app first time). After this, I want use the same spinner on a different style (app is loaded, but I'm loading some data while I use the app).

Someone did it before? Some tip about the best way to do this?

I'm using Angular 6 on asp.net core.

--
Stackoverflow question: https://stackoverflow.com/q/52079478/3783143

Not able to show the spinner from feature module .

it is working fine when i call show() method on root module i.e. app-module .
( tag is define inside the app-root-component.html)

But in case of calling of from the feature module it is not showing the spinner .

Spinner icon is not "hidding"

Hi,

I am showing the spinner. Processing HTTP requests and then hiding spinner. I show alert box after hidding the spinner but alert box show up before hidding the spinner.

Template code

<ngx-spinner
bdColor = "rgba(51,51,51,0.8)"
size = "default"
color = "#e6513d"
type = "timer"
></ngx-spinner>

Component code:

placeOrder() {
    const currentDate = this._datePipe.transform(new Date(), 'dd-MMM-yyy');

    let addressId;
    const addAddressBody = {
      Address: this.address.value,
      UserId: this._user.id,
      Type: 'Home'                    // TODO : Remove hardcoded value
    };
    this._checkoutService.addAddress(addAddressBody)
      .subscribe(response => {

        // Starting spinner
        this._spinner.show();

        addressId = response;

        const placeOrderApiBody = {
          USERID : this._user.id,
          SUBTOTAL: this._subTotalAmount,
          DELIVERYCHARGE: this.DELIVERY_CHARGE,
          TAX: this._municipalityTax,
          GRANDTOTAL: this._grossTotalAmount,
          ADDRESS: addressId,
          INSTRUCTIONS: this.chefInstruction.value,
          VENDORID: this._user.cart.restaurantId,
          DRIVERINSTRUCTION: this.driverInstruction.value,
          DELIVERYDATE: currentDate,
          DELIVERYTIME: 'As Soon As Possible',
          MOBILENO: this.phoneNumber.value,
          LATITUDE: this._user.address.lat,
          LONGITUDE: this._user.address.lng
        };

        this._checkoutService.placeOrder(placeOrderApiBody).subscribe(
          placeOrderResponseJson => {
            // Get order id
            const orderId = placeOrderResponseJson[0].ORDERID;

            // Send order details to server.
            const items = this._user.cart.cartItems;

            let index = 0;
            for (index = 0; index < items.length; index++) {

              const placeOrderDetailApiBody = {
                ORDERID: orderId,
                PRODUCTID: items[index].productId,
                QUANTITY: items[index].quantity,
                PRICE: items[index].unitPrice,
              };

              this._checkoutService.sendOrderDetails(placeOrderDetailApiBody)
                .subscribe( sendOrderDetailsResponseJson => {
                });
            }

            // Hidding spinner.
            this._spinner.hide();

            // Emptying cart for next order to avoid duplicates.
            this._user.cart = new Cart();

            // TODO : Show modal insted of alert.
            alert('Order successful!');

            this._router.navigate(['/location']);
          }
        );
      });
  }

Disable full screen

I was planning on using the spinner inside a div and when I add it to my component it goes on full screen. I wounder if its possible to give an option to be full screen or not, and if you select not the spinner would display inside your div.

How to put spinner in button?

Hi, I would like to put the spinner in a button, or in a custom position (for example inside a div, ecc). I've tried putting the inside my button, but it's still displaying on the center of the page, even with the fullScreen="false". How can I achieve this?

ExpressionChangedAfterItHasBeenCheckedError

NgxSpinnerComponent.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: false'. Current value: 'ngIf: true'.
at viewDebugError (core.js:7386)
at expressionChangedAfterItHasBeenCheckedError (core.js:7374)
at checkBindingNoChanges (core.js:7476)
at checkNoChangesNodeInline (core.js:10337)
at checkNoChangesNode (core.js:10326)
at debugCheckNoChangesNode (core.js:10929)
at debugCheckDirectivesFn (core.js:10857)
at Object.eval [as updateDirectives] (NgxSpinnerComponent.html:1)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:10846)
at checkNoChangesView (core.js:10225)

At:

{{loadingText}}

My Use:

public subjectLoading = new Subject();

this.subjectLoading.subscribe((p) => {
if (p === true) {
this.spinner.show();
} else {
this.spinner.hide();
}
})

Using fullscreen=false fits whole module instead of parent div

Ngx-spinner Version 7.0.0
Angular version: 7.2.2

Code in component template:

<div *ngIf="!formActive">{{jsonFormStatusMessage}}
<ngx-spinner
    bdOpacity = 0.9
    bdColor = "#333"
    size = "default"
    color = "#fff"
    type = "ball-pulse"
    fullScreen = "false"
    >
    <p style="color: white" > Loading... </p>
</ngx-spinner>
</div>

Expected behavior: spinner covering only the div containing my component.

Effective behavior: spinner covers the whole root module.

good job! Need animations)

Very well and affordable did. But it would be even better if you added animation and text editing, and thank you very much!

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.