firewire-angular
v1.0.7
Published
firewire | a modular ecosystem for building firebase apps in express.
Downloads
1
Maintainers
Readme
firewire-angular | firebase + express + angular
Use in conjunction with firewire - https://www.npmjs.com/package/firewire
firewire + firewire-angular = no wait time for firebase data (providing read access is granted).
how it works
- firewire loads firebase in node.js which is much much faster than client-side firebase load.
- firewire-angular hardwires that data into angular so it doesn't need to wait for firebase on the client-side.
- It then loads firebase up and seamlessly switches the hardwired data to realtime data.
install
Follow instructions @ https://www.npmjs.com/package/firewire
Install firewire-angular into your public node_modules
npm install firewire-angular --save
Add these dependencies to your jade template (assuming that you're running npm3+)
// npm 3+ should load firebase + angulafire + firewire-angular into /node_modules ... If using < 3 these directories will need to be altered. //- firebase script(src="/node_modules/firebase/lib/firebase-web.js") //- angularfire script(src="/node_modules/angularfire/dist/angularfire.min.js") //- firewire-angular script(src="/node_modules/firewire-angular/firewire.js")
get Started
Paste this script into your jade template before your other scripts.
//- load firewire object
script.
var fw = !{firewire};
In your angular app add the firewire module
var app = angular.module('app', [
"firewireModule"
]);
This will assign fw
to $rootScope.fw
allowing you to just use {{fw.some.data}}
in your templates or $rootScope.fw.some.data
in your js.
Remember to inject $rootScope into any controllers, services, etc. that you need to access $rootScope.fw
In the background firewire-angular is using angularfire (angular's bindings for firebase) so you can now do things like ng-click = "fw.some.data.$save()"
right in your template to save data back to firebase.
Adding arrays
firewire-angular exposes 2 services (fb and fbref).
fb is your firebase url (eg. https://example.firebase.com) and fbref is your firebase reference to it.
Furthermore $rootScope.fwMap contains your firebase data routes.
So you can use angularfire's $firebaseArray(fbref.child($rootScope.fwMap[childRoute]); to assign a firebase array to a firewire route.
You'll just need to inject $firebaseArray and fbref into your controller (etc.)
Auth, login screens, etc.
Check out https://www.npmjs.com/package/firewire-angular-auth