Angular 1.5和ES6 - 导入模块

时间:2016-05-29 21:22:56

标签: angularjs es6-shim

我试图利用Angular 1.5中的新功能,并通过Babel使用Webpack和ES6。

在一个案例中,我想引入一个模块(ngStorage),但ngStorage是用经典的1.x风格编写的。所以这个文件:

import angular from 'angular';
import ngStorage from 'ngstorage';
import UserSettings from './user-settings';
import UserFactory from './user.factory';

let userModule = angular.module('user', [ngStorage])

    .service('UserSettings', UserSettings)
    .factory('User', UserFactory);

export default userModule;

在运行时导致此错误:

Error: [$injector:modulerr] Failed to instantiate module user due to:
Error: [$injector:modulerr] Failed to instantiate module {"_invokeQueue":[["$provide","provider",{"0":"$localStorage"}],["$provide","provider",{"0":"$sessionStorage"}]],"_configBlocks":[],"_runBlocks":[],"requires":[],"name":"ngStorage"} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object

我猜我无法从ngstorage导入 - 它不会导出任何东西。有没有办法可以重新加载1.x依赖项以便导入它们?

0 个答案:

没有答案