Making an Ionic Hybrid Mobile Application with Angular.js and Firebase

Part 1

Setting things up

cd Rexpenses
ionic platform add android
ionic build android
ionic emulate android

Get Started

Modifying the View and the Controller

Adding Firebase

angular.module(‘starter’, [‘ionic’, ‘starter.controllers’, ‘starter.services’,’firebase’])

Firebase Data References Side-Note

https://<yourfirebase>.firebaseio.com/expenses
.controller('DashCtrl', function($scope, fireBaseData, $firebase) {
$scope.expenses = $firebase(fireBaseData.refExpenses()).$asArray();
$scope.addExpense = function(e) {
$scope.expenses.$add({
by: < someemail > ,
label: $scope.label,
cost: $scope.cost
});
$scope.label = "";
$scope.cost = 0;
};
$scope.getTotal = function() {
var rtnTotal = 0;
for (var i = 0; i < $scope.expenses.length; i++) {
rtnTotal += $scope.expenses[i].cost;
}
return rtnTotal;
};
})

Authorization

{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}

--

--