-
Add the Firebase and AngularFire libraries to
index.html
.<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script> <script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
-
Add
'firebase'
as an app level module dependency. -
Create a new Firebase app instance (on http://firebase.com).
-
Store the Firebase instance address into a constant (in
app.js
).angular.module(...).constant('FBURL', 'vivid-inferno-8565.firebaseio.com')
-
Structure the JSON data in the just created Firebase app. Delete the
data
folder from the project. -
Edit the
Pizza
service to get all pizzas from the Firebase app instance.angular.module(...).factory('Pizza', function pizzaService(FBURL, $firebaseArray) { var ref = new Firebase(FBURL + '/pizzas'); return { getPizzas: function() { return $firebaseArray(ref); } } });
-
Call the
getPizzas()
function from thepizza-list.js
controller instead of the "old" service. -
Update the
pizza-list.html
view to generate links with the built-in$id
instead of the self-declaredid
. -
Update the
Pizza
service to get single pizza information from the Firebase app instance.angular.module(...).factory('Pizza', function pizzaService(FBURL, $firebaseArray, $firebaseObject) { var ref = new Firebase(FBURL + '/pizzas'); return { ... getPizza: function(id) { var pizzaRef = new Firebase(FBURL + '/pizzas/' + id); return $firebaseObject(pizzaRef); } } });
-
Consequently, call the
getPizza()
function from thepizza-detail.js
controller.
-
Notifications
You must be signed in to change notification settings - Fork 0
SoNet-2016/social-prototype-firebase
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Integrate AngularFire and Firebase in Pizza++
Resources
Stars
Watchers
Forks
Packages 0
No packages published