如何在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;