Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Arquvio da minha directive
- var app = angular.module('myApp', []);
- app.directive('alertDirective', [function () {
- return {
- restrict: 'AE',
- template: '<div class="alert alert-success text-center"><p>{{ title }}:<b ng-transclude>Msg Alert!</b></p></div>',
- scope: {
- title: '@',
- },
- transclude: true
- };
- }])
- //Meu app.js
- 'use strict';
- // Declare app level module which depends on views, and components
- angular.module('myApp', [
- 'ngRoute',
- 'myApp.home',
- 'myApp.register',
- 'myApp.welcome'
- ]).
- config(['$routeProvider', function($routeProvider) {
- $routeProvider.otherwise({redirectTo: '/register'});
- }]);
- //Controller que quero chamar a directive
- 'use strict';
- angular.module('myApp.register', ['ngRoute', 'firebase'])
- .config(['$routeProvider', function($routeProvider) {
- $routeProvider.when('/register', {
- templateUrl: 'js/controllers/register/register.html',
- controller: 'registerCtrl'
- });
- }])
- .controller('registerCtrl', ['$scope','$location', function(
- $scope, $location, $firebaseAuth, $rootScope) {
- $scope.msg = "";
- var rootRef = firebase.database().ref();
- $scope.user = {};
- $scope.signIn = function() {
- var email = $scope.user.email;
- var password = $scope.user.password;
- if(!email || !password) {
- console.log('Sorry you not found credentials!');
- // $location.path('/home');
- }
- firebase.auth().signInWithEmailAndPassword(email, password)
- .catch(function(error) {
- var errorCode = error.code;
- var errorMessage = error.message;
- });
- firebase.auth().onAuthStateChanged(function(user) {
- if (user) {
- var email = "";
- var passowrd = "";
- $scope.msg = "Successfully added user.";
- console.log(user);
- } else {
- // No user is signed in.
- }
- });
- }
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement