以严格模式调用

Invoking in strict mode

本文关键字:调用 模式      更新时间:2023-09-26

我有一个配置对象:

jwtOptionsProvider.config({
        tokenGetter: (store) => {
            return store.get('token');
        },
        whiteListedDomains: ['localhost']
    });

但是,我启用了严格模式,得到以下错误:

tokenGetter没有使用显式注释,不能在严格模式下调用

我知道$inject,但在这种情况下如何正确使用它?

试试

jwtOptionsProvider.config({
    tokenGetter: ['store', (store) => {
        return store.get('token');
    }],
    whiteListedDomains: ['localhost']
});

看到https://github.com/auth0/angular-jwt i-have-minification-problems-with-angular-jwt-in-production-whats-going-on

我的解决方案:

function tokenGetter(store) {
    return store.get('token');
}
tokenGetter.$inject = ['localStorageService'];
jwtOptionsProvider.config({
    tokenGetter: tokenGetter,
    whiteListedDomains: ['localhost']
});