Hi,
 
I am getting access token after login, but I want to store access token using angularjs.
 
This is my angular controllor :
 
LoginController :
 
(function () {
'use strict';
angular.module('MyApp') // extending from previously created angular module in the First Part
.controller('LoginController',function ($scope,$location,$window, LoginService)
{
$scope.IsLogedIn = false;
$scope.Message = '';
$scope.Submitted = false;
$scope.IsFormValid = false;
$scope.User = {
UserName: '',
Password: ''
};
//Check is Form Valid or Not // Here f1 is our form Name
$scope.$watch('f1.$valid', function (newVal) {
$scope.IsFormValid = newVal;
});
$scope.Login = function () {
$scope.Submitted = true;
if ($scope.IsFormValid) {
LoginService.GetUser($scope.User).then(function (d) {
debugger;
if (d.data.AccessToken != null) {
$scope.IsLogedIn = true;
$scope.Message = "Successfully login done. Welcome ";
$window.location.href = "/Home/index";
}
else {
$scope.Message = "Invalid UserName or Password";
}
});
}
};
})
.factory('LoginService', function ($http,$q,$window) {
var fac = {};
debugger;
fac.GetUser = function (d) {
return $http({
url: 'api/users/login',
method: 'POST',
data: JSON.stringify(d),
headers: { 'content-type': 'application/json' }
});
};
return fac;
});
})();
 
This is my login view :
 
{{Message}}

Username required

Password required

OR



@section scripts{
}
Please tell me how to store access token after login.
 
Thank you.