What is Firebase?
Role of a backend in an Angular App
Building a TODO app with Angular + Firebase
User Authentication and Security
Build Apps fast - no servers required!
Data persistence, but in realtime
With authentication & security rules, serves as the complete backend
Build Apps fast wihout worrying about data binding
Declaratively specify views in plain HTML
<body ng-app>
<div ng-controller="MyApp">
<input type="text" ng-model="name"/><br/>
<h1 ng-cloak>Hi {{name}}!</h1>
</div>
</body>
<body ng-app="myModule">
<div ng-controller="myApp">
<input type="text" ng-model="name"/><br/><h1>Hi {{name}}!</h1>
</div>
</body>
<script>
angular.module("myModule", ["firebase"]).
controller("myApp", function($scope, angularFire) {
var url = "https://anant.firebaseio.com/angular";
angularFire(url, $scope, "name", "");
});
</script>
AngularFire provides an easy way to integrate user login via JSON Web Tokens.
Convenience wrappers over Facebook, Github, Twitter and Persona.
<body ng-controller="MyController">
<span ng-show="user">
{{user.name}} | <a href="#" ng-click="logout()">Logout</a>
</span>
<a href="#" ng-hide="user" ng-click="login()">Login</a>
<script>
function MyController($scope, angularFireAuth) {
var url = "https://anant.firebaseio.com/";
angularFireAuth.initialize(url, {scope: $scope, name: "user"});
$scope.login = function() {
angularFireAuth.login("facebook");
};
$scope.logout = function() {
angularFireAuth.logout();
};
}
</script>
</body>
Security in a client-only app has always been a big open question
Tie it to authentication and express logic as lightweight expressions
{
"rules": {
"$userid": {
".read": true,
".write": "auth.id == $userid"
}
}
}