ngx-spinner
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,0 +0,0 @@ import { ModuleWithProviders } from '@angular/core'; |
@@ -0,0 +0,0 @@ import { Component, Injectable, NgModule } from '@angular/core'; |
@@ -0,0 +0,0 @@ import { OnDestroy } from '@angular/core'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { Subject } from 'rxjs/Subject'; |
@@ -0,0 +0,0 @@ (function (global, factory) { |
{ | ||
"name": "ngx-spinner", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -5,3 +5,3 @@ # ngx-spinner | ||
To install this library, run: | ||
To install `ngx-spinner`, run: | ||
@@ -12,11 +12,10 @@ ```bash | ||
## Consuming your library | ||
## Example | ||
Once you have published your library to npm, you can import your library in any Angular application by running: | ||
For working example see below Plunker: | ||
https://plnkr.co/edit/vwWmv3mj8jUYA8ArHfXM?p=preview | ||
```bash | ||
$ npm install ngx-spinner | ||
``` | ||
## Usage | ||
and then from your Angular `AppModule`: | ||
Once you successfully installed library by runnig above command, now import required files in your `AppModule`: | ||
@@ -29,4 +28,4 @@ ```typescript | ||
// Import your library | ||
import { SampleModule } from 'ngx-spinner'; | ||
// Import library module | ||
import { NgxSpinnerModule, NgxSpinnerService } from 'ngx-spinner'; | ||
@@ -40,6 +39,6 @@ @NgModule({ | ||
// Specify your library as an import | ||
LibraryModule | ||
// Specify library as an import | ||
NgxSpinnerModule | ||
], | ||
providers: [], | ||
providers: [NgxSpinnerService], // Provide spinner service to hide/show spinner | ||
bootstrap: [AppComponent] | ||
@@ -50,24 +49,28 @@ }) | ||
Once your library is imported, you can use its components, directives and pipes in your Angular application: | ||
Once you imported module and service, you can use its hide/show method of service in your `AppComponent`: | ||
```xml | ||
<!-- You can now use your library component in app.component.html --> | ||
<h1> | ||
{{title}} | ||
</h1> | ||
<sampleComponent></sampleComponent> | ||
``` | ||
```typescript | ||
import { Component, OnInit } from '@angular/core'; | ||
import { NgxSpinnerService } from 'ngx-spinner'; | ||
## Development | ||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html' | ||
}) | ||
class AppComponent implements OnInit { | ||
constructor(private spinner: NgxSpinnerService) { } | ||
To generate all `*.js`, `*.d.ts` and `*.metadata.json` files: | ||
ngOnInit() { | ||
this.spinner.show(); // Call this method to show spinner | ||
```bash | ||
$ npm run build | ||
this.spinner.hide(); // Call this method to hide spinner | ||
} | ||
} | ||
``` | ||
To lint all `*.ts` files: | ||
Now use selector in your `app.component.html` | ||
```bash | ||
$ npm run lint | ||
```xml | ||
<!-- You can now use library component in app.component.html --> | ||
<ngx-spinner></ngx-spinner> | ||
``` | ||
@@ -77,2 +80,2 @@ | ||
MIT © [Yuvraj Chauhan](mailto:yuvrajchauhan41@gmail.com) | ||
MIT © [Yuvraj Chauhan](mailto:yuvrajchauhan3113@gmail.com) |
19875
76