Skip to content

Commit b7b115c

Browse files
authored
Merge branch 'master' into @somombo/add-list-set
2 parents 42fb3b9 + 29144e2 commit b7b115c

18 files changed

+1366
-359
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ typings/
66
npm-debug.log
77
.idea/
88
.vscode/settings.json
9+
angularfire2-*.tgz

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
<a name="4.0.0-rc.1"></a>
2+
# [4.0.0-rc.1](https://github.com/angular/angularfire2/compare/4.0.0-rc.0...v4.0.0-rc.1) (2017-06-02)
3+
4+
### Breaking changes
5+
6+
* **rc:** Update to Firebase JS SDK 4.0 ([9642f5](https://github.com/angular/angularfire2/commit/9642f589ba73add6d49a5818a1109028f8c7729b))
7+
8+
In version 4.0 of the Firebase SDK `onAuthStateChanged` is only fired on sign-in and sign-out, [see the Firebase JS SDK changelog for more information.](https://firebase.google.com/support/release-notes/js#4.0.0). The added `AngularFireAuth.idToken: Observable<firebase.User>` behaves as `authState` used to.
9+
10+
<a name="4.0.0-rc0"></a>
11+
# [4.0.0-rc0](https://github.com/angular/angularfire2/compare/2.0.0-beta.8...v4.0.0-rc0) (2017-05-02)
12+
13+
14+
### Bug Fixes
15+
16+
* **auth:** Use the injected app ([980c447](https://github.com/angular/angularfire2/commit/980c447))
17+
* **build:** Add package.json files for deep paths ([cd5f2d1](https://github.com/angular/angularfire2/commit/cd5f2d1)), closes [#880](https://github.com/angular/angularfire2/issues/880)
18+
* **database:** Fix test TypeScript errors ([750737c](https://github.com/angular/angularfire2/commit/750737c)), closes [#875](https://github.com/angular/angularfire2/issues/875)
19+
* **database:** use switchMap when a list's query changes ([#831](https://github.com/angular/angularfire2/issues/831)) ([b85147d](https://github.com/angular/angularfire2/commit/b85147d)), closes [#830](https://github.com/angular/angularfire2/issues/830)
20+
21+
22+
### Features
23+
24+
* **auth:** New Auth API ([12aa422](https://github.com/angular/angularfire2/commit/12aa422))
25+
* **database:** Add AngularFireDatabaseModule ([b388627](https://github.com/angular/angularfire2/commit/b388627))
26+
* **database:** support optional endAt/equalTo key ([#838](https://github.com/angular/angularfire2/issues/838)) ([e146492](https://github.com/angular/angularfire2/commit/e146492)), closes [#837](https://github.com/angular/angularfire2/issues/837)
27+
* **rc:** Implement rc0 API ([398e4e2](https://github.com/angular/angularfire2/commit/398e4e2))
28+
29+
130
<a name="2.0.0-beta.8"></a>
231
# [2.0.0-beta.8](https://github.com/angular/angularfire2/compare/2.0.0-beta7...v2.0.0-beta.8) (2017-02-16)
332

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Status: Beta
1414
- **Authentication** - Monitor authentication state in realtime.
1515

1616
#### Quick links
17-
[Contributing](https://github.com/angular/angularfire2/blob/master/CONTRIBUTING.md)
17+
[Contributing](CONTRIBUTING.md)
1818

1919
[Plunker Template](http://plnkr.co/edit/8yY4tH?p=preview) - Requires to set your Firebase credentials in `app.module.ts`.
2020

21+
[Upgrading to v4.0? Check out our guide.](docs/version-4-upgrade.md)
22+
2123
## Install
2224

2325
```bash
@@ -28,7 +30,7 @@ npm install firebase angularfire2 --save
2830

2931
```ts
3032
import {Component} from '@angular/core';
31-
import {AngularFire, FirebaseListObservable} from 'angularfire2';
33+
import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database';
3234

3335
@Component({
3436
selector: 'project-name-app',
@@ -42,8 +44,8 @@ import {AngularFire, FirebaseListObservable} from 'angularfire2';
4244
})
4345
export class MyApp {
4446
items: FirebaseListObservable<any[]>;
45-
constructor(af: AngularFire) {
46-
this.items = af.database.list('/items');
47+
constructor(db: AngularFireDatabase) {
48+
this.items = db.list('/items');
4749
}
4850
}
4951
```
@@ -59,3 +61,4 @@ productive with AngularFire2.
5961
4. [Querying lists](docs/4-querying-lists.md)
6062
5. [User Authentication - FirebaseAuthentication](docs/5-user-authentication.md)
6163
6. [Using AngularFire2 with Ionic 2](docs/Auth-with-Ionic2.md)
64+
7. [Using AngularFire2 with Ionic 3 and Angular 4](docs/Auth-with-Ionic3-Angular4.md)

docs/1-install-and-setup.md

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> Getting started with AngularFire2 is easy with the [Angular CLI](https://github.com/angular/angular-cli). Follow the 10 steps below to get started. Don't worry, we're always working to make this shorter.
44
5+
> Using Ionic and the Ionic CLI? Check out these [specific instructions](6-angularfire-and-ionic-cli.md) for Ionic and their CLI.
6+
57
### 0. Prerequisites
68

79
Before you start installing AngularFire2, make sure you have latest version of angular-cli installed.
@@ -56,7 +58,25 @@ npm install angularfire2 firebase --save
5658

5759
Now that you have a new project setup, install AngularFire2 and Firebase from npm.
5860

59-
### 4. Setup @NgModule
61+
### 4. Add Firebase config to environments variable
62+
63+
Open `/src/environments/environment.ts` and add your Firebase configuration:
64+
65+
```ts
66+
export const environment = {
67+
production: false,
68+
firebase: {
69+
apiKey: '<your-key>',
70+
authDomain: '<your-project-authdomain>',
71+
databaseURL: '<your-database-URL>',
72+
projectId: '<your-project-id>',
73+
storageBucket: '<your-storage-bucket>',
74+
messagingSenderId: '<your-messaging-sender-id>'
75+
}
76+
};
77+
```
78+
79+
### 5. Setup @NgModule for the AngularFireModule
6080

6181
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
6282
This can be found in your project at [the Firebase Console](https://console.firebase.google.com):
@@ -66,20 +86,12 @@ import { BrowserModule } from '@angular/platform-browser';
6686
import { NgModule } from '@angular/core';
6787
import { AppComponent } from './app.component';
6888
import { AngularFireModule } from 'angularfire2';
69-
70-
// Must export the config
71-
export const firebaseConfig = {
72-
apiKey: '<your-key>',
73-
authDomain: '<your-project-authdomain>',
74-
databaseURL: '<your-database-URL>',
75-
storageBucket: '<your-storage-bucket>',
76-
messagingSenderId: '<your-messaging-sender-id>'
77-
};
89+
import { environment } from '../environments/environment';
7890

7991
@NgModule({
8092
imports: [
8193
BrowserModule,
82-
AngularFireModule.initializeApp(firebaseConfig)
94+
AngularFireModule.initializeApp(environment.firebase)
8395
],
8496
declarations: [ AppComponent ],
8597
bootstrap: [ AppComponent ]
@@ -95,55 +107,87 @@ You can optionally provide a custom FirebaseApp name with `initializeApp`.
95107
@NgModule({
96108
imports: [
97109
BrowserModule,
98-
AngularFireModule.initializeApp(firebaseConfig, authConfig, 'my-app-name')
110+
AngularFireModule.initializeApp(environment.firebase, 'my-app-name')
99111
],
100112
declarations: [ AppComponent ],
101113
bootstrap: [ AppComponent ]
102114
})
103115
export class AppModule {}
104116
```
105117

118+
### 6. Setup individual @NgModules
119+
120+
After adding the AngularFireModule you also need to add modules for the individual @NgModules that your application needs.
121+
- AngularFireAuthModule
122+
- AngularFireDatabaseModule
123+
- AngularFireStorageModule (Future release)
124+
- AngularFireMessagingModule (Future release)
125+
126+
#### Adding the Firebase Database and Auth Modules
127+
128+
For example if your application was using both Firebase authentication and the Firebase database you would add:
129+
130+
```ts
131+
import { BrowserModule } from '@angular/platform-browser';
132+
import { NgModule } from '@angular/core';
133+
import { AppComponent } from './app.component';
134+
import { AngularFireModule } from 'angularfire2';
135+
import { AngularFireDatabaseModule } from 'angularfire2/database';
136+
import { AngularFireAuthModule } from 'angularfire2/auth';
137+
import { environment } from '../environments/environment';
138+
139+
@NgModule({
140+
imports: [
141+
BrowserModule,
142+
AngularFireModule.initializeApp(environment.firebase, 'my-app-name'), // imports firebase/app needed for everything
143+
AngularFireDatabaseModule, // imports firebase/database, only needed for database features
144+
AngularFireAuthModule, // imports firebase/auth, only needed for auth features
145+
],
146+
declarations: [ AppComponent ],
147+
bootstrap: [ AppComponent ]
148+
})
149+
export class AppModule {}
150+
151+
```
106152

107-
### 5. Inject AngularFire
153+
### 7. Inject AngularFireDatabase
108154

109155
Open `/src/app/app.component.ts`, and make sure to modify/delete any tests to get the sample working (tests are still important, you know):
110156

111157
```ts
112158
import { Component } from '@angular/core';
113-
import { AngularFire, FirebaseListObservable } from 'angularfire2';
159+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
114160

115161
@Component({
116-
117162
selector: 'app-root',
118163
templateUrl: 'app.component.html',
119164
styleUrls: ['app.component.css']
120165
})
121166
export class AppComponent {
122-
constructor(af: AngularFire) {
167+
constructor(db: AngularFireDatabase) {
123168

124169
}
125170
}
126171

127172
```
128173

129-
### 6. Bind to a list
174+
### 8. Bind to a list
130175

131176
In `/src/app/app.component.ts`:
132177

133178
```ts
134179
import { Component } from '@angular/core';
135-
import { AngularFire, FirebaseListObservable } from 'angularfire2';
180+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
136181

137182
@Component({
138-
139183
selector: 'app-root',
140184
templateUrl: 'app.component.html',
141185
styleUrls: ['app.component.css']
142186
})
143187
export class AppComponent {
144188
items: FirebaseListObservable<any[]>;
145-
constructor(af: AngularFire) {
146-
this.items = af.database.list('/items');
189+
constructor(db: AngularFireDatabase) {
190+
this.items = db.list('/items');
147191
}
148192
}
149193
```
@@ -158,7 +202,7 @@ Open `/src/app/app.component.html`:
158202
</ul>
159203
```
160204

161-
### 7. Run your app
205+
### 9. Run your app
162206

163207
```bash
164208
ng serve

0 commit comments

Comments
 (0)