我正在使用webpack将文件与angular 1.x捆绑在一起 使捆绑面临
的问题我的第一个文件是我写的app.js
var sampleApp = angular.module('kinatorApp', ['ui.router','ngCookies','oc.lazyLoad','ngResource','ngDraggable','restangular','oi.select','ui.bootstrap','toastr','LocalStorageModule','ngMessages','ngMaterial','ngScrollable']);
我的第二个文件是parentController.js 我的代码在哪里
sampleApp.controller("parentCtrl", ['$scope','$rootScope','$compile','$http','$filter','$state','userServices','labelServices','sharedValues','groupServices','channelListService','parentControllerServices','toastr','positioningDataServices','$mdDialog', '$mdMedia', '$window','notification',
function($scope,$rootScope,$compile,$http,$filter,$state,userServices,labelServices,sharedValues,groupServices,channelListService,parentControllerServices,toastr,positioningDataServices,$mdDialog, $mdMedia, $window,notification) {}]);
在webpack中我通过
包含这两个文件 require('./public/app.js');
require('./public/ParentController.js');
我的捆绑包是通过在index.html中加载它成功制作的,它说
Uncaught ReferenceError: sampleApp is not defined
at Object.<anonymous> (bundle.js:471)
at Object.122 (bundle.js:1200)
at __webpack_require__ (vendor.js:55)
at Object.120 (bundle.js:13)
at __webpack_require__ (vendor.js:55)
at webpackJsonpCallback (vendor.js:26)
at bundle.js:1
无法从包
中的app.js文件获取sampleApp然后我通过
使sampleApp成为一个全局变量externals: {
'sampleApp': ''
}
但它也有效 我正在使用角度1.x