0
我想用angularjs使用webpack,但是無法讓我的控制器工作,當我嘗試要求它並運行它時出現此錯誤:__webpack_require__(...) is not a function
。下面是我的app.js和控制器代碼:需要帶有webpack的AngularJs控制器
//app.js
var angular = require('angular');
var weatherModule = angular.module('weather', []);
require('./shared/directives/app.directives')(weatherModule);
require('./weather/weather.controller')(weatherModule);
//weather.controller.js
module.export = function(weatherModule) {
weatherModule.controller('WeatherCtrl', ['$scope', function($scope){
$scope.greetings = 'Hey from controller';
}]);
}
如果我直接寫控制器代碼在app.js本身工作正常,如:weatherModule.controller('WeatherCtrl', ['$scope', function($scope){}])