如何在angularjs的localstorage中从URL保存“ access_token”?

时间:2019-05-18 16:14:12

标签: javascript angularjs ecmascript-6 local-storage query-string

如何在angularjs es6的$onInit方法中从本地存储中的URL写入access_token?当我在“应用程序”->“本地存储”选项卡中查看开发工具时,为token分配了值undefined

import queryString from 'query-string';

class AppController {
    constructor($window, $location) {
        'ngInject'
        this.$window = $window;
        this.$location = $location;
    }

    $onInit() {
        this.$window.localStorage['token'] = 
            this.$location.search().access_token;
    } 

}

export default AppController;

0 个答案:

没有答案