Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JayKan/angularfire2

Repository files navigation

AngularFire2

Build Status

Status: In-Development

API

AngularFire Service

The recommended way to take advantage of the AngularFire library is to use the injectable AngularFire service.

import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {Observable} from 'rxjs/Observable';
import {FIREBASE_PROVIDERS, defaultFirebase, AngularFire} from 'angularfire2';
import {Question} from './services/question';
@Component({
 template:`
 <ul>
 <li *ngFor="#question of questions | async">
 {{question.text}}
 </li>
 </ul>
 `
})
class App {
 questions:Observable<Question[]>
 constructor(af:AngularFire) {
 // Get an observable of a synchronized array from <firebase-root>/questions
 this.questions = af.list('/questions');
 }
}
bootstrap(App, [
 // Common injectable providers from the AngularFire lib
 FIREBASE_PROVIDERS,
 // Tell AngularFire the base URL for the Firebase used throughout
 defaultFirebase('https://<some-firebase>.firebaseio.com')
]);

FIREBASE_PROVIDERS

Contains all AngularFire provider configuration for Angular's dependency injection.

Type: any[]

Usage:

import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';
import {FIREBASE_PROVIDERS} from 'angularfire2';
bootstrap(App, FIREBASE_PROVIDERS);

defaultFirebase

Define the root url for the library, to resolve relative paths.

Type: string

Usage:

import {bootstrap} from 'angular2/platform/browser';
import {FIREBASE_PROVIDERS, defaultFirebase} from 'angularfire2';
bootstrap(App, [
 FIREBASE_PROVIDERS,
 defaultFirebase('https://my.firebaseio.com')
]);

FirebaseRef

Injectable symbol to create a Firebase reference based on the url provided by FirebaseUrl.

Type: Firebase

Usage:

import {Inject} from 'angular2/core';
import {FirebaseRef} from 'angularfire2';
...
class MyComponent {
 constructor(@Inject(FirebaseRef) ref:Firebase) {
 ref.on('value', this.doSomething);
 }
}

FirebaseUrl

URL for the app's default Firebase database.

Type: string

Usage:

import {bootstrap} from 'angular2/platform/browser';
import {Inject} from 'angular2/core';
import {FirebaseUrl, FIREBASE_PROVIDERS, defaultFirebase} from 'angularfire2';
@Component({
 selector: 'app',
 template: `<a [href]="url">{{ url }}</a>`
})
class App {
 constructor(@Inject(FirebaseUrl) public url: string) {}
}
bootstrap(App, [
 FIREBASE_PROVIDERS,
 defaultFirebase('https://my.firebaseio.com')
]);

FirebaseAuth

Injectable service for managing authentication state. It currently only supports reading auth state.

Type: class FirebaseAuth extends ReplaySubject<FirebaseAuthState>

Usage:

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>
 `
})
class App {
 constructor (@Inject(FirebaseAuth) public auth: FirebaseAuth) {}
}

FirebaseListObservable

Subclass of rxjs Observable which also has methods for updating list-like Firebase data.

type: class

additional methods:

add:(val) => void: Add an element to the Firebase ref.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 73.7%
  • JavaScript 22.7%
  • HTML 3.5%
  • Shell 0.1%

AltStyle によって変換されたページ (->オリジナル) /