npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng2-firebase

v1.0.0

Published

An Angular 2 Wrapper for the Firebase JavaScript SDK

Downloads

23

Readme

ng2-firebase

A rich Angular 2 wrapper library for the Firebase JavaScript SDK.

| master | all | | ------------- | ------------- | | wercker status | wercker status | | wercker status | wercker status |

Installation

npm install --save ng2-firebase

Usage

There are two valid ways to use the library in your project:

  • TypeScript
  • JavaScript (ES5)

TypeScript - Demo Application

To use in your project, reference the ng2-firebase/core module:

// myfile.ts
import {FirebaseModule} from 'ng2-firebase/core';

also make sure you include the Firebase JavaScript SDK:

<!-- index.html -->
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>

Add the path to your System.config({}):

System.config({
  // ...
  defaultJSExtensions: true,
  map: {
    'ng2-firebase': 'node_modules/ng2-firebase'
  }
});

Register the FirebaseModule in your root module:

// app.module.ts
import {NgModule} from '@angular/core';
import {FirebaseModule} from 'ng2-firebase/core';

@NgModule({
    imports: [
        // ... other dependencies
        FirebaseModule.forRoot({ url: 'https://myfirebaseurl.firebase.io' })
        // ... other dependencies
    ]
})
export class AppModule {}

Then use it in your component:

import {FirebaseService} from 'ng2-firebase/core';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular App!</h1>'
})
export class AppComponent {
    constructor(private firebase: FirebaseService) { }
}

JavaScript - Demo Application

Make sure that both the Firebase SDK and the Firebase Angular 2 Bundle are included:

<!-- index.html -->
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
<script src="node_modules/ng2-firebase/bundles/ng2-firebase-all.umd.js"></script>

Register the provider:

// app.module.js
(function (app) {
    app.AppModule =
        ng.core.NgModule({
            imports: [ ng2Firebase.FirebaseModule.forRoot({ url: 'https://myfirebaseurl.firebase.io' }) ]
        })
        .Class({
            constructor: function() {}
        });
})(window.app || (window.app = {}));

Use in a component:

(function(app) {
    app.AppComponent = ng.core
        .Component({
            selector: 'my-app',
            template: '<h1>My First Angular App!</h1>'
        })
        .Class({
            constructor: [ng2Firebase.FirebaseService, function(firebaseService) {
                this.firebaseService = firebaseService;
            }],
        });
})(window.app || (window.app = {}));

If you are not using a module system, then all of the exported services and classes from the ng2-firebase library are in the ng2Firebase global variable.

Demo

TypeScript and JavaScript implementations of the Angular 2 Tutorial "Tour of Heroes" application have been created at the following repository: ng2-firebase-demo.