Sani Yusuf PRO
Founder Of Haibrid. Co-Organiser Of Ionic UK. I Am Good At Making You Want To Use Ionic.
An Introduction to using Firebase with Ionic
Looking For Co Founders
Web
Unfortunately I am not, you are likely not too.
If you are let me know if you need a mobile developer :)
Backend As A Service Is The New Trend
Easily deployable solution
Quickly save and access data via CRUD operations
Authentication provision
Integration with our already existing tools
Integrates with you favourite framework
Gives one heck of a free entry package
Ionic is built on Angular
Firebase <3 Ionic
app.controller("MyCtrl", ["$scope", "$firebaseObject",
function($scope, $firebaseObject) {
var ref = new Firebase(URL);
var obj = $firebaseObject(ref);
// to take an action after the data loads, use the $loaded() promise
obj.$loaded().then(function() {
console.log("loaded record:", obj.$id, obj.someOtherKeyInData);
// To iterate the key/value pairs of the object, use angular.forEach()
angular.forEach(obj, function(value, key) {
console.log(key, value);
});
});
// To make the data available in the DOM, assign it to $scope
$scope.data = obj;
// For three-way data bindings, bind it to the scope instead
obj.$bindTo($scope, "data");
}
]);
May the demo gods be with us
app.controller("MyAuthCtrl", ["$scope", "$firebaseAuth",
function($scope, $firebaseAuth) {
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
$scope.authObj = $firebaseAuth(ref);
$scope.authObj.$authWithPassword({
email: "my@email.com",
password: "mypassword"
}).then(function(authData) {
console.log("Logged in as:", authData.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
}
]);
$scope.authObj.$createUser({
email: "my@email.com",
password: "mypassword"
}).then(function(userData) {
console.log("User " + userData.uid + " created successfully!");
return $scope.authObj.$authWithPassword({
email: "my@email.com",
password: "mypassword"
});
}).then(function(authData) {
console.log("Logged in as:", authData.uid);
}).catch(function(error) {
console.error("Error: ", error);
});
$scope.authObj.$authWithOAuthPopup("google").then(function(authData) {
console.log("Logged in as:", authData.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
By Sani Yusuf
A quick intro to Firebase with Ionic
Founder Of Haibrid. Co-Organiser Of Ionic UK. I Am Good At Making You Want To Use Ionic.