Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS和RequireJS-未捕获错误:无模块:MyApp_Javascript_Jquery_Html_Angularjs_Require - Fatal编程技术网

Javascript AngularJS和RequireJS-未捕获错误:无模块:MyApp

Javascript AngularJS和RequireJS-未捕获错误:无模块:MyApp,javascript,jquery,html,angularjs,require,Javascript,Jquery,Html,Angularjs,Require,我正在尝试用requireJS创建一个新的angular项目 这是我的index.html: <!doctype html> <html ng-app="MainApp"> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta charset="UTF-8"> <meta name="viewport" c

我正在尝试用requireJS创建一个新的angular项目

这是我的index.html:

<!doctype html>

<html ng-app="MainApp">

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <script data-main="js/requirejs.config.js" src="common/lib/requirejs/require.js"></script>

    <title>{{'TITLE' | translate}}</title>

    <link rel="stylesheet" href="common/lib/bootstrap-3.1.1-dist/css/bootstrap.css">

    <link rel="stylesheet" href="css/app.css">
</head>

<body ng-controller="MainCtrl" ng-cloak class="ng-cloak">
    <button type="button" class="btn btn-default btn-lg">
        <span class="glyphicon glyphicon-star"></span>{{'HELLO' | translate}}
    </button>
</body>

</html>
在加载index.html的浏览器上每第二次点击F5,我就会收到以下错误:

"[$injector:nomod] Module 'MainApp' is not available! You either misspelled the module name or   forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
你知道为什么吗

另外,删除ng app=MainApp标签并在加载dom后手动引导angular解决了这个问题,但我担心我做错了什么,我想确认一下

编辑-这是我的app.js:

define(["angular", "config"], function(angular) {
    return angular.module('MainApp', ['common']);
});
这是我的config.js:

require.config({
baseUrl: 'common',
paths: {
    angular         : 'lib/angular-1.2.19/angular',
    jquery          : 'lib/jquery/jquery-2.1.1',
    uibootstrap     : 'lib/ui-bootstrap-0.11.0/ui-bootstrap-tpls-0.11.0',
    bootstrap       : 'lib/bootstrap-3.1.1-dist/js/bootstrap',
    app             : '../js/app',
    config          : '../js/config'
},
shim : {
    angular : {
        exports: 'angular'
    },
    jquery : {
        exports: 'jquery'
    },
    uibootstrap : {
        exports: 'uibootstrap'
    },
    bootstrap : {
        exports: 'bootstrap'
    }
},
// To remove urlArgs on production
urlArgs: "v=" +  (new Date()).getTime() * Math.random()
});

require([
'../js/MainCtrl'
]);
define([
"angular",
"constants/constants",
"values/values",
"filters/filters",
"services/services",
"factories/factories",
"directives/directives",
"providers/providers",
"controllers/controllers"
], function(angular) {  

return angular.module('common', [
    'common.factories',
    'common.services',
    'common.directives',
    'common.providers',
    'common.constants',
    'common.values',
    'common.controllers',
    'common.filters'
]);
});

只需检查直接父文件夹的名称中是否有空格字符,就我的情况而言,我的文件夹结构类似于…/in Progress/AngularSample/

我也有同样的问题,而且代码中显然没有问题,我最终将parentfolder名称从InProgress更改为InProgress,它开始正常工作

你们有叫common的模块吗?