Ich bin mit angularjs Login auf meiner Website tun. Mein Code:
HTML:Cookies mit Routing angularjs
<input type="text" ng-model="username" placeholder="Username">
<input type="password" ng-model="password" placeholder="Password" >
<button class="btn btn-lg btn-primary btn-block" type="submit" ng-click="signin()">Sign in</button>
JS:
app.config(function($routeProvider) {
$routeProvider
.when('/', {
resolve: {
"check": function($location, $rootScope) {
if(!$rootScope.valueCookie) {
$location.path('/login');
}
}
},
templateUrl: 'home.html'
})
.when('/login', {
templateUrl: 'login.html'
})
.otherwise({
redirectTo: '/'
});
});
$scope.signin = function() {
$rootScope.valueCookie = $cookieStore.put('obj', someSessionObj);
}
Was ich versuche, ist entschlossen, Cookies zu tun. Wenn Cookies in einem Browser sind - nachdem Sie sich angemeldet haben und wir uns in "home.html" befinden, befindet sich nach der Refresh-Seite immer noch "home.html". Mein Code funktioniert nicht. Vielen Dank für die Antworten im Voraus.