首先介绍我的环境。我使用的是Windows7,StS IDE和关键的tc服务器,google Chrome。
我构建了一个angularJS应用程序。下面是我的index.jsp
的代码<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My AngularJS App</title>
<script src="<c:url value="resources/js/angular.min.js"/>"></script>
<script src="<c:url value="resources/js/angular-route.min.js"/>"></script>
<script src="<c:url value="resources/js/angular-resource.min.js"/>"></script>
<script src="<c:url value="resources/js/bootstrap.min.js"/>"></script>
<script src="<c:url value="app/view1/FormView.js"/>"></script>
<script src="<c:url value="app/view1/controller.js"/>"></script>
<script src="<c:url value="app/view1/services.js"/>"></script>
<script src="<c:url value="app/view2/Form2View.js"/>"></script>
<script src="<c:url value="app/view2/controller.js"/>"></script>
<script src="<c:url value="app/view2/service.js"/>"></script>
<script src="<c:url value="app/js/bootstrap.min.js"/>"></script>
<script src="<c:url value="app/myApp.js"/>"></script>
<link rel="stylesheet" href="<c:url value ="resources/css/bootstrap.min.css"/>">
<link rel="stylesheet" href="<c:url value ="app/view1/app.css"/>">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body data-ng-app= "myApp">
<ul class="menu">
<li><a href="#/view1">LookUpCodeStyle</a></li>
<li><a href="#/view2">AccountMaster</a></li>
</ul>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div data-ng-view></div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
-->
</body>
</html>
在服务器上部署时,会抛出以下错误:
Uncaught TypeError: undefined is not a function
Uncaught TypeError: undefined is not a function
Uncaught TypeError: undefined is not a function
Uncaught TypeError: undefined is not a function
Uncaught Error: No module: ngResource
但我定义的最重要的事情是:
<body data-ng-app= "myApp">
日食引发了一个错误:
Cannot find module with name myApp.
我有myApp.js:
angular.module('myApp', [
'ngRoute',
'myApp.form',
'myApp.form2'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
顺便说一句,它正在加载所有文件。我检查了网络。 任何帮助将不胜感激?
答案 0 :(得分:0)
尝试将ngResource添加到myApp模块。
angular.module('myApp', [
'ngRoute',
'ngResource',
'myApp.form',
'myApp.form2'
])
答案 1 :(得分:0)
我对AngularJS for Eclipse遇到了同样的问题:Cannot find module with name MyApp
,即使Angular Explorer中列出了MyApp
。解决方法是从config
声明中取消链接MyApp
,如下所示:
var app = angular.module('myApp', [
'ngRoute',
'myApp.form',
'myApp.form2'
]);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/view1'});
}]);