$http.get('http://localhost:8080/TestProjetJersyAngularJs/rest/LoginServices/login', config)
.then(function(data) {
var data = data.data;
if (data == "Administrateur" || data == "Utilisateur") {
switch (data) {
case 'Administrateur':
alert("in case admin");
alert("arg 0 in case admin : " + arg0);
$cookieStore.put('arg0', arg0);
$scope.roleAdmin = data;
$location.path('/accueil');
break;
case 'Utilisateur':
alert("in case user");
$cookieStore.put('arg0', arg0);
$scope.roleUser = data;
$location.path('/accueil');
break;
default:
}
$scope.arg0 = $cookieStore.get('arg0');
alert("scope arg 0 : " + $scope.arg0)
} else if (data == "error") {
$scope.errorMsg = "donnees incorrecte!!";
$location.path('/');
}
});
答案 0 :(得分:0)
<!DOCTYPE html>
<html data-ng-app="myApp" >
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="resources/Js/angular.min.js"></script>
<script type="text/javascript" src="resources/Js/angular-route.min.js"></script>
<script type="text/javascript" src="resources/Js/angular-cookies.min.js"></script>
<script type="text/javascript" src="resources/Js/Controller.js"></script>
</head>
<body>
<h1>hiiiiiiiiii angularJs</h1>
<div data-ng-controller="demoCtrl">
Bonjour : {{arg0}} <br>
role :{{ roleUser }} <br>
<a href="" data-ng-click="logout()" target="_self">Log Out</a><br>
<a href="" data-ng-click="newPage()" target="_self">newPageTest</a>
</div>
</body>
</html>