Saturday, September 30, 2017

AngularJS login two different files

I have 2 files, one you have to login and the other one you are logged in.

This is the form login:

var monarchApp = angular.module('monarchApp', ['ngRoute']);
  monarchApp.controller('loginController', function($scope, $rootScope, $location){
    $scope.username = "admin";
    $scope.password = "pass";
    if($scope.username == "admin" && $scope.password == 'pass'){
      $rootScope.loginStatus = true;
      console.log($rootScope.loginStatus);
      window.location.replace('main.html');
    }
  });

But when I’m at the Main.html is can’t find the $rootScope.loginStatus.
I thing the problem is window.location.replace(); that he does not take the rootScopes with him.

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/09/30/angularjs-login-two-different-files/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment