Skip to content

Instantly share code, notes, and snippets.

@ManishLSN
Created December 29, 2017 10:36
Show Gist options
  • Save ManishLSN/a0c0bd76aea0f31c0b1ff46678497d88 to your computer and use it in GitHub Desktop.
Save ManishLSN/a0c0bd76aea0f31c0b1ff46678497d88 to your computer and use it in GitHub Desktop.
set header in angular js application
//$window.location.reload();
//$state.go("login");
$cookies.put("token", response.token);
var value = $cookies.get("token");
/* $cookies.put("loginUserId", response[0].id);
$rootScope.loginUserId = $cookies.get("loginUserId"); */
localStorageService.set("loginUserId", response.id);
$rootScope.loginUserId = localStorageService.get('loginUserId');
localStorageService.set("isSuperAdmin", response.isSuperAdmin);
$rootScope.isSuperAdmin = localStorageService.get('isSuperAdmin');
/* $cookies.put("isSuperAdmin", response[0].isSuperAdmin);
$rootScope.isSuperAdmin = $cookies.get("isSuperAdmin"); */
$http.defaults.headers.common.Authorization = response.token;
if(response.isSuperAdmin == '3')
$state.go("header.fre_order");
else
$state.go("home.dashboard");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment