Skip to content

Commit

Permalink
update api-reference.md (authentication usage) (angular#347)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ChrisCurrin authored and davideast committed Jul 11, 2016
1 parent 7946bd7 commit eab7627
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,32 @@ import {FirebaseAuth} from 'angularfire2';
@Component({
selector: 'auth-status',
template: `
<div *ng-if="auth | async">You are logged in</div>
<div *ng-if="!(auth | async)">Please log in</div>
<div *ngIf="auth | async">You are logged in</div>
<div *ngIf="!(auth | async)">Please log in</div>
`
})
class App {
constructor (@Inject(FirebaseAuth) public auth: FirebaseAuth) {}
}
```
Alternatively, if you wish to extend an existing AngularFire component to monitor authentication status:
```
ts
import {AngularFire, FirebaseAuth} from 'angularfire2';
@Component({
selector: 'auth-status',
template: `
<div *ngIf="af.auth | async">You are logged in</div>
<div *ngIf="!(af.auth | async)">Please log in</div>
`
})
class App {
constructor(public af: AngularFire) {
this.af.auth.subscribe(auth => console.log(auth));
}
}
```
### FirebaseListObservable

Subclass of rxjs `Observable` which also has methods for updating
Expand Down

0 comments on commit eab7627

Please sign in to comment.