以下代码在我的本地开发环境中工作正常,但是当我在服务器上托管解决方案时,我得到以下错误,在使用未经编译的js后,我收到以下错误:
angular.js:66 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
ReferenceError: shallowCopy is not defined
下面是相关的代码,我的index.php文件,包括所有文件和注入我的指令的app.js文件:
的index.php:
<!-- bootstrap/jquery -->
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<script src="js/jquery/jquery-3.1.1.min.js"></script>
<script src="js/jquery/jquery-ui.min.js"></script>
<link rel="stylesheet" href="styles/jquery/jquery-ui.min.css" />
<link rel="stylesheet" href="styles/bootstrap-3.3.7-dist/css/bootstrap.css" />
<script src="styles/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="plugins/Bootstrap-3-Typeahead-master/bootstrap3-typeahead.min.js"></script>
<!-- end bootstrap/jquery -->
<!-- custom css -->
<link rel="stylesheet" href="styles/styles.css" />
<!-- end custom css -->
<!-- favicon -->
<link rel='shortcut icon' type='image/x-icon' href='media/images/favicon.ico' />
<!-- end favicon -->
<!-- custom js -->
<script src="js/main.js"></script>
<!-- end custom js -->
<!-- angularjs -->
<script src="js/angularjs/angular.min.js"></script>
<script src="js/angularjs/angular-route.min.js"></script>
<script src="js/angularjs/angular-sanitize.js"></script>
<script src="js/app.js"></script>
<script src="js/login/login.js"></script>
<script src="js/questionnaire/questionnaire.js"></script>
<script src="js/study/study.js"></script>
<script src="js/result/result.js"></script>
<!-- end angularjs -->
<div class="row" ng-app="app" >
<div ng-view>
</div>
</div>
app.js:
// app.js
(function () {
"use strict";
// Creating the Module
angular.module("app", ["ngRoute", "ngSanitize"])
.config(function ($routeProvider) {
//$location.path('/questionnaire'); //logged in already, session still active
$routeProvider.when("/", {
controller: "loginController",
controllerAs: "vm",
templateUrl: "views/login.php"
});
$routeProvider.when("/questionnaire/", {
controller: "questionnaireController",
controllerAs: "vm",
templateUrl: "views/questionnaire.php"
});
$routeProvider.when("/questionnaire/:survey", {
controller: "questionnaireController",
controllerAs: "vm",
templateUrl: "views/questionnaire.php"
});
$routeProvider.when("/study/:studyid", {
controller: "studyController",
controllerAs: "vm",
templateUrl: "views/study.php"
});
$routeProvider.when("/result/", {
controller: "resultController",
controllerAs: "vm",
templateUrl: "views/result.php"
});
$routeProvider.otherwise({ redirectTo: "/" });
});
})();
答案 0 :(得分:0)
这可能是js缩小的问题,参考https://docs.angularjs.org/guide/di#implicit-annotation
请尝试以下操作,请注意[&#39; $ routeProvider ...:
用这个
替换你的代码(function () {
"use strict";
angular.module("app", ["ngRoute", "ngSanitize"])
.config(['$routeProvider', function ($routeProvider) {
//$location.path('/questionnaire'); //logged in already, session still active
$routeProvider.when("/", {
controller: "loginController",
controllerAs: "vm",
templateUrl: "views/login.php"
});
$routeProvider.when("/questionnaire/", {
controller: "questionnaireController",
controllerAs: "vm",
templateUrl: "views/questionnaire.php"
});
$routeProvider.when("/questionnaire/:survey", {
controller: "questionnaireController",
controllerAs: "vm",
templateUrl: "views/questionnaire.php"
});
$routeProvider.when("/study/:studyid", {
controller: "studyController",
controllerAs: "vm",
templateUrl: "views/study.php"
});
$routeProvider.when("/result/", {
controller: "resultController",
controllerAs: "vm",
templateUrl: "views/result.php"
});
$routeProvider.otherwise({ redirectTo: "/" });
}]);
})();
答案 1 :(得分:0)
我有同样的问题。
我通过将最近添加的插件包含移到我底部的位置来解决此问题 bundles.Add(在我的应用程序开始中添加了新的ScriptBundle
此更改对我有用,它在本地运行良好,但在实际环境中崩溃了。