Guest User

Untitled

a guest
Sep 15th, 2016
102
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. password: 'P@ssw0rd'
  17. }
  18. };
  19.  
  20. $scope.register = function(newUserInfo){
  21. $firebase.createUser(newUserInfo,
  22. function(userInfo){
  23. $ionicPopup.alert({
  24. title: 'Registration Success',
  25. template: 'Successfully created user account for ' + userInfo.email
  26. }).then(function(){
  27. newUserInfo.email = null;
  28. newUserInfo.password = null;
  29. });
  30. }, function(error){
  31. $ionicPopup.alert({
  32. title: 'Registration Failed',
  33. template: error.message
  34. });
  35. }
  36. );
  37. }
  38.  
  39. // Panggil fungsi registrasi di controller ini, bisa di taro di dalam submit event
  40. $scope.register($scope.models.newUser);
  41.  
  42. }
  43. ])
  44.  
  45. ;
  46.  
  47. })();
Advertisement
Add Comment
Please, Sign In to add comment