我的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'
                });
        }]
    );add.controller
    MyApp.controller("AddController", function ($scope, EmpApi) { ....... }当我运行应用程序时,我得到'MyApp‘是未定义的。我做错了什么?我对webpack和安古拉杰都是新手。你能告诉我怎么解决这个问题吗?谢谢
发布于 2020-08-06 19:03:44
控制器文件中未定义'MyApp‘,因此必须将控制器添加到'MyApp’模块中
变化
MyApp.controller("AddController", function ($scope, EmpApi) { ....... }至
angular.module('MyApp').controller("AddController", function ($scope, EmpApi) { ....... }https://stackoverflow.com/questions/54815765
复制相似问题