File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,14 @@ import {
1616 FirebaseAuthState
1717} from './providers/auth_backend' ;
1818import { FirebaseSdkAuthBackend } from './providers/firebase_sdk_auth_backend' ;
19+ import { FirebaseDatabase } from './database/database' ;
1920
2021@Injectable ( )
2122export class AngularFire {
2223 constructor (
2324 @Inject ( FirebaseUrl ) private fbUrl :string ,
24- public auth :FirebaseAuth ) {
25+ public auth :FirebaseAuth ,
26+ public database : FirebaseDatabase ) {
2527 }
2628 list ( url :string , opts ?:FirebaseListFactoryOpts ) :FirebaseListObservable < any [ ] > {
2729 return FirebaseListFactory ( getAbsUrl ( this . fbUrl , url ) , opts ) ;
Original file line number Diff line number Diff line change 1+ import { Inject } from 'angular2/core' ;
2+ import { FirebaseUrl } from '../tokens' ;
3+ import { FirebaseListObservable } from '../utils/firebase_list_observable' ;
4+ import { FirebaseObjectObservable } from '../utils/firebase_object_observable' ;
5+ import { FirebaseListFactory , FirebaseListFactoryOpts } from '../utils/firebase_list_factory' ;
6+ import { FirebaseObjectFactoryOpts , FirebaseObjectFactory } from '../utils/firebase_object_factory' ;
7+
8+ export class FirebaseDatabase {
9+ constructor ( @Inject ( FirebaseUrl ) private fbUrl :string ) { }
10+ list ( url :string , opts ?:FirebaseListFactoryOpts ) :FirebaseListObservable < any [ ] > {
11+ return FirebaseListFactory ( getAbsUrl ( this . fbUrl , url ) , opts ) ;
12+ }
13+ object ( url : string , opts ?:FirebaseObjectFactoryOpts ) :FirebaseObjectObservable < any > {
14+ return FirebaseObjectFactory ( getAbsUrl ( this . fbUrl , url ) , opts ) ;
15+ }
16+ }
17+
18+ function getAbsUrl ( root :string , url :string ) {
19+ if ( ! ( / ^ [ a - z ] + : \/ \/ .* / . test ( url ) ) ) {
20+ // Provided url is relative.
21+ url = root + url ;
22+ }
23+ return url ;
24+ }
You can’t perform that action at this time.
0 commit comments