尝试使用webpack for angularjs启动并运行。尝试为/ webpack&中的每个文件夹设置不同的角度模块。然后将它们注入我的主app模块定义。我做错了什么?
遇到此错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module mean due to:
Error: [$injector:modulerr] Failed to instantiate module webpack due to:
Error: [$injector:modulerr] Failed to instantiate module {"_invokeQueue":[],"_configBlocks":[],"_runBlocks":[],"requires":[],"name":"photocropper"} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object
入口点:
var angular = require('angular');
ngModule = angular.module('webpack', [
require('./webpack/photocrop/client')
])
./的WebPack / photocrop /客户端/ index.js
var angular = require('angular');
module.exports = angular.module('photocropper', [])
答案 0 :(得分:1)
请记住,您需要在依赖项
中传递模块名称而不是模块ngModule = angular.module('webpack', [
require('./webpack/photocrop/client')//this is a object
])
你可以简单地要求文件,只需按名称注入就像这样
var firstModule = require(' ./ webpack / photocrop / client')
ngModule = angular.module('webpack', [
'firstModule'//this is should work
])
firstModule(ngModule)
还有其他方法来制作应用程序击球手look into this seed
答案 1 :(得分:0)
我遇到了同样的问题,在我的情况下,它通过更改分配来解决:
var angular = require('angular');
简单地说:
require('angular');
原因是这个分配正在创造一个新的"角度"变量与Angular本身提供的变量不同,因此,它没有“模块”。属性