【发布时间】:2019-02-21 20:33:56
【问题描述】:
我的 webpack.config
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: "./main.js", //relative to root of the application
output: {
path: __dirname,
filename: "app.bundle.js" //relative to root of the application
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
title: 'My Awesome application',
myPageHeader: 'interviewee',
template: './_index.html',
filename: 'index.html' //relative to root of the application
})
]
}
main.js
let jquery = require("./Scripts/jquery-1.9.0.js");
let angular = require("./Scripts/angular.js");
let ngRoute = require("./Scripts/angular-route.js");
let bootstrap = require("./Scripts/bootstrap.js");
let appController = require("./app.controller.js");
let addController = require("./add.controller.js");
let service = require("./service.js");
let messages = require("./Scripts/angular-messages.js")
app.controller
var MyApp = angular.module("MyApp", [
'ngRoute',
'ngMessages',
'IntervieweeService'
]
);
MyApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/Add', {
templateUrl: 'Views/add.html',
controller: 'AddController'
}).
otherwise({
redirectTo: '/Home'
});
}]
);
添加控制器
MyApp.controller("AddController", function ($scope, EmpApi) { ....... }
当我运行应用程序时,我得到“MyApp”未定义。我究竟做错了什么?我是 webpack 和 angularjs 的新手。你能告诉我如何解决这个问题吗?谢谢
【问题讨论】:
-
这是缩小角码吗?