import { Component } from '@angular/core';
import { SpinnerService } from 'angular-spinners';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor(public spinnerService: SpinnerService) {}
}


/*
Copyright 2017 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://v2.angular.io/license
*/
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';
import { SpinnerModule } from 'angular-spinners';

@NgModule({
  imports:      [ BrowserModule, SpinnerModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }


/*
Copyright 2017 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://v2.angular.io/license
*/
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);


/*
Copyright 2017 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://v2.angular.io/license
*/
<!DOCTYPE html>
<html>
  <head>
    <title>Angular Quickstart</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
      body {color:#369;font-family: Arial,Helvetica,sans-serif;}
    </style>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css" />

    <!-- Polyfills -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>

    <script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
      System.import('main.js').catch(function(err){ console.error(err); });
    </script>
  </head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>

</html>


<!-- 
Copyright 2017 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://v2.angular.io/license
-->
/**
 * WEB ANGULAR VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es2015", "dom"],
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // 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/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs@5.0.1',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@5.2.7/lib/plugin.js',
      'typescript':                'npm:typescript@2.0.10/lib/typescript.js',
      'angular-spinners':          'npm:angular-spinners'

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts',
        meta: {
          './*.ts': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });

})(this);

/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://v2.angular.io/license
*/
var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm;
var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g;
var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;

module.exports.translate = function(load){
  var url = document.createElement('a');
  url.href = load.address;

  var basePathParts = url.pathname.split('/');

  basePathParts.pop();
  var basePath = basePathParts.join('/');

  var baseHref = document.createElement('a');
  baseHref.href = this.baseURL;
  baseHref = baseHref.pathname;

  basePath = basePath.replace(baseHref, '');

  load.source = load.source
    .replace(templateUrlRegex, function(match, quote, url){
      let resolvedUrl = url;

      if (url.startsWith('.')) {
        resolvedUrl = basePath + url.substr(1);
      }

      return 'templateUrl: "' + resolvedUrl + '"';
    })
    .replace(stylesRegex, function(match, relativeUrls) {
      var urls = [];

      while ((match = stringRegex.exec(relativeUrls)) !== null) {
        if (match[2].startsWith('.')) {
          urls.push('"' + basePath + match[2].substr(1) + '"');
        } else {
          urls.push('"' + match[2] + '"');
        }
      }

      return "styleUrls: [" + urls.join(', ') + "]";
    });

  return load;
};
<div class="main-area">
  <div class="control-panel">
    <h3>Spinner Demo</h3>
    <hr>
    <div *ngFor="let index of [1,2,3,4,5,6]">
      <button
        class="btn btn-success btn-sm"
        (click)="spinnerService.show('spinner' + index)">
        Show Spinner {{index}}
      </button>
      <button
        class="btn btn-danger btn-sm"
        (click)="spinnerService.hide('spinner' + index)">
        Hide Spinner {{index}}
      </button>
    </div>
    <hr>
    <div *ngFor="let group of ['foo','bar','baz']">
      <button
        class="btn btn-success btn-sm"
        (click)="spinnerService.showGroup(group)">
        Show Group {{group}}
      </button>
      <button
        class="btn btn-danger btn-sm"
        (click)="spinnerService.hideGroup(group)">
        Hide Group {{group}}
      </button>
    </div>
    <hr>
    <button
      class="btn btn-success btn-sm"
      (click)="spinnerService.showAll()">
      Show All
    </button>
    <button
      class="btn btn-danger btn-sm"
      (click)="spinnerService.hideAll()">
      Hide All
    </button>
  </div>
  <div class="spinners">
    <div class="spinner">
      <spinner name="spinner1" group="foo">
        <div class="double-bounce1 foo"></div>
        <div class="double-bounce2 foo"></div>
      </spinner>
    </div>
    <div class="spinner">
      <spinner name="spinner2" group="baz">
        <div class="double-bounce1 baz"></div>
        <div class="double-bounce2 baz"></div>
      </spinner>
    </div>
    <div class="spinner">
      <spinner name="spinner3" group="bar">
        <div class="double-bounce1 bar"></div>
        <div class="double-bounce2 bar"></div>
      </spinner>
    </div>
    <div class="spinner">
      <spinner name="spinner4" group="foo">
        <div class="double-bounce1 foo"></div>
        <div class="double-bounce2 foo"></div>
      </spinner>
    </div>
    <div class="spinner">
      <spinner name="spinner5" group="bar">
        <div class="double-bounce1 bar"></div>
        <div class="double-bounce2 bar"></div>
      </spinner>
    </div>
    <div class="spinner">
      <spinner name="spinner6" group="baz">
        <div class="double-bounce1 baz"></div>
        <div class="double-bounce2 baz"></div>
      </spinner>
    </div>
  </div>
</div>
body {
  background-color: #777;
}

.double-bounce1, .double-bounce2 {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #333;
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  
  -webkit-animation: sk-bounce 2.0s infinite ease-in-out;
  animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}

@-webkit-keyframes sk-bounce {
  0%, 100% { -webkit-transform: scale(0.0) }
  50% { -webkit-transform: scale(1.0) }
}

@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0);
    -webkit-transform: scale(0.0);
  } 50% { 
    transform: scale(1.0);
    -webkit-transform: scale(1.0);
  }
}
body {
  font-family: arial;
  padding: 15px;
}

button.btn {
  margin-bottom: 5px;
}

.foo {
  background-color: #900;
}
.bar {
  background-color: #009;
}
.baz {
  background-color: #090;
}

.control-panel {
  border: solid 5px #000;
  padding: 15px;
  border-radius: 15px;
  width: 300px;
  text-align: center;
  background-color: #ddd;
  display: inline-block;
  margin-top: 25px;
}

hr {
  border-color: #000;
}

.spinners {
  display: inline-block;
  border: solid 0px #000;
  border-radius: 15px;
  margin-left: 15px;
  padding: 15px;
  width: 100px;
  vertical-align: top;
  margin-top: 25px;
}

.spinner {
  background-color: #ddd;
  display: block;
  margin-top: 10px;
  width: 75px;
  height: 75px;
  position: relative;
  border: solid 5px #000;
  border-radius: 50%;
}

.spinner img {
  width: 100%;
  height: 100%;
}

.main-area {
  width: 500px;
  margin: auto;
}