Advertisement
Guest User

Untitled

a guest
Sep 15th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // Requirement Firebase JS SDK
  2.  
  3. (function(){
  4. 'use strict';
  5.  
  6. angular.module('ContohRegisterFirebase', [
  7. 'ionic',
  8. 'FirebaseService' // include dari file firebase-service.js
  9. ])
  10.  
  11. .controller('RegisterPageCtrl', ['$scope', '$firebase', '$ionicPopup',
  12. function($scope, $firebase, $ionicPopup){
  13.  
  14. $scope.models = {
  15. newUser: {
  16. email: 'tester@domain.com',
  17. password: 'P@ssw0rd'
  18. }
  19. };
  20.  
  21. $scope.register = function(newUserInfo){
  22. $firebase.createUser(newUserInfo,
  23. function(userInfo){
  24. $ionicPopup.alert({
  25. title: 'Registration Success',
  26. template: 'Successfully created user account for ' + userInfo.email
  27. }).then(function(){
  28. newUserInfo.email = null;
  29. newUserInfo.password = null;
  30. });
  31. }, function(error){
  32. $ionicPopup.alert({
  33. title: 'Registration Failed',
  34. template: error.message
  35. });
  36. }
  37. );
  38. }
  39.  
  40. // Panggil fungsi registrasi di controller ini, bisa di taro di dalam submit event
  41. $scope.register($scope.models.newUser);
  42.  
  43. }
  44. ])
  45.  
  46. ;
  47.  
  48. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement