Possuo o seguinte codigo:
app.controller("LoginCtrl", function ($scope, LoginAPI) {
$scope.doLogin = function (model) {
if (model.username === undefined || model.password === undefined) {
return false;
}
LoginAPI.post(model).success(function (results) {
localStorage.removeItem('token');
//Armazena o token no localStorage
localStorage.setItem('token', JSON.stringify(results));
//pegando so o token
console.log(results);
})
.error(function (Error) {
console.log(Error);
})
};
});
a variável results me devolve a seguinte informação:
{**"access_token":"RBIuaO8f4xsSrEUgWoPA8w1EcuRW2U1vSIGiIzzCzsPwCibo1SHRtIYWZVfpFQmW17nzJ-hQsIE4wJBZpTfZi4_OYg1EMrCyEJwWg7nN4mq7-tGwKF8cDhMlruxKBa_lVzpoUBtSB1l0UfEXwb8a-PIsWJ6LGu7uG525xLy-5stVLdrbe3nh54iygNwdyY14GlBjbrBmnWxYzRJ_5UnA7klIk-DpW3vybll24RVMgD-nR1EI-ckdRPana-nySYsYNgElwq7PSQrSr2NHavZmyo-8vMT_BcGYYF5h9dWSZoSbaE8t8II2DaM2sZL-9KLS50SMBZ1N6oPsUv2D7uI3f1qM8EsK5GQ21tG-Lt3_DHwofE_aIKvmHo2CmFTd910HBSJpR63iwMwL-9VTOT6r98u85YWP6WZxGJWJFoMmY4ek0AEjDqbvn1QQOvGBlnJzJ4wfJtqBeEt_RAIubvmg-2tS4JMaAMC-oNz904dIk_3j1RzVfjQL9CtS8eYJNcjY"**,"token_type":"bearer","expires_in":1209599,"userName":"[email protected]",".issued":"Mon, 13 Mar 2017 18:11:11 GMT",".expires":"Mon, 27 Mar 2017 18:11:11 GMT"}
Preciso transformar este conjunto de string em um objeto e pegar o valor do token que é o access_token que esta de negrito. Como resolvo este problema?