Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. //Arquvio da minha directive
  2. var app = angular.module('myApp', []);
  3.  
  4. app.directive('alertDirective', [function () {
  5. return {
  6. restrict: 'AE',
  7. template: '<div class="alert alert-success text-center"><p>{{ title }}:<b ng-transclude>Msg Alert!</b></p></div>',
  8. scope: {
  9. title: '@',
  10. },
  11. transclude: true
  12. };
  13. }])
  14.  
  15. //Meu app.js
  16. 'use strict';
  17.  
  18. // Declare app level module which depends on views, and components
  19. angular.module('myApp', [
  20. 'ngRoute',
  21. 'myApp.home',
  22. 'myApp.register',
  23. 'myApp.welcome'
  24.  
  25. ]).
  26. config(['$routeProvider', function($routeProvider) {
  27. $routeProvider.otherwise({redirectTo: '/register'});
  28. }]);
  29.  
  30. //Controller que quero chamar a directive
  31. 'use strict';
  32.  
  33. angular.module('myApp.register', ['ngRoute', 'firebase'])
  34.  
  35. .config(['$routeProvider', function($routeProvider) {
  36. $routeProvider.when('/register', {
  37. templateUrl: 'js/controllers/register/register.html',
  38. controller: 'registerCtrl'
  39. });
  40. }])
  41. .controller('registerCtrl', ['$scope','$location', function(
  42. $scope, $location, $firebaseAuth, $rootScope) {
  43.  
  44. $scope.msg = "";
  45. var rootRef = firebase.database().ref();
  46.  
  47. $scope.user = {};
  48.  
  49. $scope.signIn = function() {
  50. var email = $scope.user.email;
  51. var password = $scope.user.password;
  52.  
  53. if(!email || !password) {
  54. console.log('Sorry you not found credentials!');
  55. // $location.path('/home');
  56. }
  57. firebase.auth().signInWithEmailAndPassword(email, password)
  58. .catch(function(error) {
  59. var errorCode = error.code;
  60. var errorMessage = error.message;
  61. });
  62. firebase.auth().onAuthStateChanged(function(user) {
  63. if (user) {
  64. var email = "";
  65. var passowrd = "";
  66. $scope.msg = "Successfully added user.";
  67. console.log(user);
  68. } else {
  69. // No user is signed in.
  70. }
  71. });
  72. }
  73. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement