Skip to content

Commit eab7627

Browse files
ChrisCurrindavideast
authored andcommitted
update api-reference.md (authentication usage) (angular#347)
under: Subscribing to Authentication State *ng-if was replaced with *ngIf (the correct Angular2 syntaxt) an extra usage was added to make it more fluid for components with AngularFire already, instead of a new component for FirebaseAuth. Fits in better with https://github.com/angular/angularfire2/blob/master/docs/5-user-authentication.md Finally, not sure if `@Inject(FirebaseAuth)` is necessary as it seems to work without it on my machine, but left it in the original usage (would probably also have to include an import statement for it in the original usage; I'll leave that to the original author.
1 parent 7946bd7 commit eab7627

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

docs/api-reference.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,32 @@ import {FirebaseAuth} from 'angularfire2';
199199
@Component({
200200
selector: 'auth-status',
201201
template: `
202-
<div *ng-if="auth | async">You are logged in</div>
203-
<div *ng-if="!(auth | async)">Please log in</div>
202+
<div *ngIf="auth | async">You are logged in</div>
203+
<div *ngIf="!(auth | async)">Please log in</div>
204204
`
205205
})
206206
class App {
207207
constructor (@Inject(FirebaseAuth) public auth: FirebaseAuth) {}
208208
}
209209
```
210+
Alternatively, if you wish to extend an existing AngularFire component to monitor authentication status:
211+
```
212+
ts
213+
import {AngularFire, FirebaseAuth} from 'angularfire2';
214+
@Component({
215+
selector: 'auth-status',
216+
template: `
217+
<div *ngIf="af.auth | async">You are logged in</div>
218+
<div *ngIf="!(af.auth | async)">Please log in</div>
219+
`
220+
})
221+
class App {
222+
constructor(public af: AngularFire) {
223+
this.af.auth.subscribe(auth => console.log(auth));
224+
}
225+
}
210226
227+
```
211228
### FirebaseListObservable
212229

213230
Subclass of rxjs `Observable` which also has methods for updating

0 commit comments

Comments
 (0)