You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Using Ionic and the Ionic CLI? Check out these [specific instructions](ionic/cli.md) for Ionic and their CLI.
4
+
5
+
### 0. Prerequisites
6
+
7
+
AngularFire provides multiple module formats for different types of builds. The guide is based off the Angular CLI. It is possible to do a manual setup with Webpack or a SystemJS build as well.
8
+
9
+
```bash
10
+
npm install @angular/cli
11
+
```
12
+
13
+
### 1. Create a new project
14
+
15
+
```bash
16
+
ng new <project-name>
17
+
cd<project-name>
18
+
```
19
+
20
+
The Angular CLI's `new` command will set up the latest Angular build in a new project structure.
21
+
22
+
### 2. Test your Setup
23
+
24
+
```bash
25
+
ng serve
26
+
open http://localhost:4200
27
+
```
28
+
29
+
You should see a message that says *App works!*
30
+
31
+
### 3. Install AngularFire and Firebase
32
+
33
+
```bash
34
+
npm install angularfire2 firebase --save
35
+
```
36
+
37
+
Now that you have a new project setup, install AngularFire and Firebase from npm.
38
+
39
+
### 4. Add Firebase config to environments variable
40
+
41
+
Open `/src/environments/environment.ts` and add your Firebase configuration. You can find your project configuration in [the Firebase Console](https://console.firebase.google.com). From the project overview page, click **Add Firebase to your web app**.
42
+
43
+
```ts
44
+
exportconst environment = {
45
+
production: false,
46
+
firebase: {
47
+
apiKey: '<your-key>',
48
+
authDomain: '<your-project-authdomain>',
49
+
databaseURL: '<your-database-URL>',
50
+
projectId: '<your-project-id>',
51
+
storageBucket: '<your-storage-bucket>',
52
+
messagingSenderId: '<your-messaging-sender-id>'
53
+
}
54
+
};
55
+
```
56
+
57
+
### 5. Setup @NgModule for the AngularFireModule
58
+
59
+
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
Copy file name to clipboardExpand all lines: docs/install-and-setup.md
+31-92
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
> Using Ionic and the Ionic CLI? Check out these [specific instructions](ionic/cli.md) for Ionic and their CLI.
4
4
5
+
> Following instructions use `ng add` command that automates several steps for you. If you want to set up things manually refer to [these steps](install-and-setup-manual.md) instead.
6
+
5
7
### 0. Prerequisites
6
8
7
9
AngularFire provides multiple module formats for different types of builds. The guide is based off the Angular CLI. It is possible to do a manual setup with Webpack or a SystemJS build as well.
@@ -26,109 +28,48 @@ ng serve
26
28
open http://localhost:4200
27
29
```
28
30
29
-
You should see a message that says *App works!*
31
+
You should see a message that says _App works!_
30
32
31
-
### 3. Install AngularFire and Firebase
33
+
### 3. Add AngularFire
32
34
33
35
```bash
34
-
npm install angularfire2 firebase --save
36
+
ng add angularfire2
35
37
```
36
38
37
-
Now that you have a new project setup, install AngularFire and Firebase from npm.
39
+
This command will install `angularfire2` and `firebase` from npm, prepare configuration variables and import AngularFire module(s) into your App's NgModule.
40
+
41
+
#### Custom FirebaseApp Names
42
+
43
+
You can optionally provide a custom FirebaseApp name by providing the `--firebaseApp=my-app-name` flag.
44
+
45
+
#### Setup individual @NgModules
38
46
39
-
### 4. Add Firebase config to environments variable
47
+
By providing the `--all` flag you can also add modules for the individual @NgModules that your application needs:
40
48
41
-
Open `/src/environments/environment.ts` and add your Firebase configuration. You can find your project configuration in [the Firebase Console](https://console.firebase.google.com). From the project overview page, click **Add Firebase to your web app**.
49
+
- AngularFirestoreModule
50
+
- AngularFireAuthModule
51
+
- AngularFireDatabaseModule
52
+
- AngularFireStorageModule
53
+
54
+
### 4. Edit Firebase config in environments variable
55
+
56
+
Open `/src/environments/environment.ts` and edit your Firebase configuration. You can find your project configuration in [the Firebase Console](https://console.firebase.google.com). From the project overview page, click **Add Firebase to your web app**.
42
57
43
58
```ts
44
59
exportconst environment = {
45
-
production: false,
46
60
firebase: {
47
61
apiKey: '<your-key>',
48
62
authDomain: '<your-project-authdomain>',
49
63
databaseURL: '<your-database-URL>',
50
64
projectId: '<your-project-id>',
51
65
storageBucket: '<your-storage-bucket>',
52
-
messagingSenderId: '<your-messaging-sender-id>'
53
-
}
66
+
messagingSenderId: '<your-messaging-sender-id>',
67
+
},
68
+
production: false,
54
69
};
55
70
```
56
71
57
-
### 5. Setup @NgModule for the AngularFireModule
58
-
59
-
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
0 commit comments