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