Skip to content

Commit ece8068

Browse files
committed
docs(ionic): follow config setup convention
1 parent b9b224e commit ece8068

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

docs/6-angularfire-and-ionic-cli.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ Now that you have a new project setup, install AngularFire2 and Firebase from np
4343

4444
### 4. Add Firebase config to environments variable
4545

46-
Your Firebase config can be added to the root `src/app/app.module.ts` or to it's own file.
47-
We'll use the root `app.module.ts` for this example.
46+
Let's create a new file, `src/environment.ts` and start adding our Firebase config:
4847

48+
```ts
49+
export const firebaseConfig = {
50+
apiKey: '<your-key>',
51+
authDomain: '<your-project-authdomain>',
52+
databaseURL: '<your-database-URL>',
53+
projectId: '<your-project-id>',
54+
storageBucket: '<your-storage-bucket>',
55+
messagingSenderId: '<your-messaging-sender-id>'
56+
}
57+
58+
```
4959

5060

5161
### 5. Setup @NgModule for the AngularFireModule
@@ -60,15 +70,7 @@ import { IonicApp, IonicModule } from 'ionic-angular';
6070
import { MyApp } from './app.component';
6171

6272
import { AngularFireModule } from 'angularfire2';
63-
64-
const firebaseConfig = {
65-
apiKey: '<your-key>',
66-
authDomain: '<your-project-authdomain>',
67-
databaseURL: '<your-database-URL>',
68-
projectId: '<your-project-id>',
69-
storageBucket: '<your-storage-bucket>',
70-
messagingSenderId: '<your-messaging-sender-id>'
71-
}
73+
import { firebaseConfig } from '../environment';
7274

7375
@NgModule({
7476
declarations: [ MyApp ],
@@ -121,17 +123,10 @@ import { IonicApp, IonicModule } from 'ionic-angular';
121123
import { MyApp } from './app.component';
122124

123125
import { AngularFireModule } from 'angularfire2';
126+
import { firebaseConfig } from '../environment';
124127
import { AngularFireDatabaseModule } from 'angularfire2/database';
125128
import { AngularFireAuthModule } from 'angularfire2/auth';
126129

127-
const firebaseConfig = {
128-
apiKey: '<your-key>',
129-
authDomain: '<your-project-authdomain>',
130-
databaseURL: '<your-database-URL>',
131-
projectId: '<your-project-id>',
132-
storageBucket: '<your-storage-bucket>',
133-
messagingSenderId: '<your-messaging-sender-id>'
134-
}
135130

136131
@NgModule({
137132
declarations: [ MyApp ],

0 commit comments

Comments
 (0)