Angularjs 角度+;网页包:初始化时为空的角度对象

Angularjs 角度+;网页包:初始化时为空的角度对象,angularjs,webpack,Angularjs,Webpack,尝试使用webpack+angular 1.5.5+ng前进。Webpack解析angular并逐模块构建它。在角度初始化过程中,我得到以下函数的错误: 出现此错误是因为角度对象为空({})。为什么会这样?如何固定它(除了将角度移动到外部) 我的网页包配置: 好的,我用两种方法解决了这个问题: 1) 在巴贝尔加载器之后的主加载器部分中使用导入加载器: 装载机:[ {test:/\.ts/,exclude:/node\u modules/,loader:'import?angular!babe

尝试使用webpack+angular 1.5.5+ng前进。Webpack解析angular并逐模块构建它。在角度初始化过程中,我得到以下函数的错误:

出现此错误是因为
角度对象为空(
{}
)。为什么会这样?如何固定它(除了将角度移动到
外部

我的网页包配置:


好的,我用两种方法解决了这个问题:

1) 在
巴贝尔加载器
之后的主加载器部分中使用
导入加载器

装载机:[
{test:/\.ts/,exclude:/node\u modules/,loader:'import?angular!babel loader!ts loader'}
]
它是有效的,但是还有一些其他的问题迫使我停止使用这种方式。因此,还有另一种方法:


2) 我刚刚创建了一个文件
vendor.js
,其中需要所有依赖项。据我所知,这是使用网页包库的正确方法。

好的,我用两种方法解决了这个问题:

1) 在
巴贝尔加载器
之后的主加载器部分中使用
导入加载器

装载机:[
{test:/\.ts/,exclude:/node\u modules/,loader:'import?angular!babel loader!ts loader'}
]
它是有效的,但是还有一些其他的问题迫使我停止使用这种方式。因此,还有另一种方法:


2) 我刚刚创建了一个文件
vendor.js
,其中需要所有依赖项。据我所知,使用webpack库是一种正确的方法。

遇到了完全相同的问题并找到了解决方案。这里的问题是angular 1不能很好地使用没有垫片的webpack(请参阅)。尝试此网页包加载程序配置:

module: {
    loaders: [
        /*
         * Necessary to be able to use angular 1 with webpack as explained in https://github.com/webpack/webpack/issues/2049
         */
        {
            test: require.resolve('angular'),
            loader: 'exports?window.angular'
        },
    ]
},
plugins: [
    new webpack.ProvidePlugin({
        'angular': 'angular',
    }),
],

遇到了完全相同的问题并找到了解决方案。这里的问题是angular 1不能很好地使用没有垫片的webpack(请参阅)。尝试此网页包加载程序配置:

module: {
    loaders: [
        /*
         * Necessary to be able to use angular 1 with webpack as explained in https://github.com/webpack/webpack/issues/2049
         */
        {
            test: require.resolve('angular'),
            loader: 'exports?window.angular'
        },
    ]
},
plugins: [
    new webpack.ProvidePlugin({
        'angular': 'angular',
    }),
],
module: {
    loaders: [
        /*
         * Necessary to be able to use angular 1 with webpack as explained in https://github.com/webpack/webpack/issues/2049
         */
        {
            test: require.resolve('angular'),
            loader: 'exports?window.angular'
        },
    ]
},
plugins: [
    new webpack.ProvidePlugin({
        'angular': 'angular',
    }),
],