1 | [![npm](https://img.shields.io/npm/v/@ionic/cloud-angular.svg?maxAge=2592000)](https://www.npmjs.com/package/@ionic/cloud-angular)
|
2 |
|
3 | # Ionic Cloud Client for Angular 2
|
4 |
|
5 | Angular 2 integration for the Ionic Cloud in your app.
|
6 |
|
7 | ## Installation
|
8 |
|
9 | ```bash
|
10 | $ npm install --save @ionic/cloud-angular
|
11 | ```
|
12 |
|
13 | ## Usage
|
14 |
|
15 | In your `app.ts` file, tell Angular about the Ionic Cloud providers by calling
|
16 | the imported `provideCloud` function with a config and passing it to
|
17 | [`ionicBootstrap`](http://ionicframework.com/docs/v2/api/config/Config/)
|
18 | function. Then, use the injectable cloud classes (`Auth`, `User`, `Push`,
|
19 | `Deploy`, etc.) in your app's classes just as you would any other service
|
20 | class.
|
21 |
|
22 | ```javascript
|
23 | import ...
|
24 | import {Auth, User, CloudSettings, provideCloud} from '@ionic/cloud-angular';
|
25 |
|
26 | const cloudSettings: CloudSettings = {
|
27 | 'core': {
|
28 | 'app_id': 'YOUR-APP-ID'
|
29 | }
|
30 | };
|
31 |
|
32 | @Component({
|
33 | template: '<ion-nav [root]="rootPage"></ion-nav>'
|
34 | })
|
35 | export class MyApp {
|
36 | rootPage: any = TabsPage;
|
37 |
|
38 | constructor(platform: Platform, public auth: Auth, public user: User) {
|
39 | platform.ready().then(() => {
|
40 | let details = {'email': 'hi@ionic.io', 'password': 'puppies123'};
|
41 | this.auth.signup(details).then(() => {
|
42 | return this.auth.login(details);
|
43 | }).then(() => {
|
44 | // `this.user` is now the authenticated user
|
45 | }, (err) => {
|
46 | // something went wrong!
|
47 | });
|
48 | });
|
49 | }
|
50 | }
|
51 |
|
52 | // Register the Ionic Cloud in the bootstrap
|
53 | ionicBootstrap(MyApp, [provideCloud(cloudSettings)]);
|
54 | ```
|