我在angular.js中使用ngRoute
时遇到错误。
错误:
angular.js:6未捕获错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.7/ $ injector / modulerr?p0 = myApp& p1 = ReferenceE ... 20%20at%20ge%20(http%3A%2F%2Flocalhost% 2Fangularjs%2Fangular.js%3A19%3A484)(匿名函数)@ angular.js:6(匿名函数)@ angular.js:40r @ angular.js:7g @ angular.js:39db @ angular.js:43c @ angular .js:20Bc @ angular.js:21ge @ angular.js:19(匿名函数)@ angular.js:316b @ angular.js:189Sf @ angular.js:37d @ angular.js:36
我正在解释下面的代码。
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><i class="fa fa-home"></i> Home</a></li>
<li><a href="#contact"><i class="fa fa-comment"></i> Contact</a></li>
<li><a href="#form"><i class="fa fa-shield"></i>Open form </a></li>
</ul>
config.js:
var app=angular.module('myApp',['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'home.html',
controller : 'mainController'
})
// route for the about page
.when('/contact', {
templateUrl : 'contact.html',
controller : 'contactController'
})
// route for the contact page
.when('/form', {
templateUrl : 'form.html',
controller : 'formController'
});
otherwise({
redirectTo: '/'
});
})
app.controller('mainController', function($scope) {
$scope.message = 'Everyone come and see This is home page!';
});
app.controller('contactController', function($scope) {
$scope.address = 'Contact us! Rasulgarh,Bhubaneswar';
});
app.controller('formController',function($scope){
})
的index.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Angularjs</title>
<script src="angular.js"></script>
<script src="angularroute.js"></script>
<script src="config.js"></script>
<script src="app.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" />
</head>
<body>
<header>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">Angular Routing and form Example</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><i class="fa fa-home"></i> Home</a></li>
<li><a href="#contact"><i class="fa fa-comment"></i> Contact</a></li>
<li><a href="#form"><i class="fa fa-shield"></i>Open form </a></li>
</ul>
</div>
</nav>
</header>
<div ng-view></div>
</body>
</html>
当我点击“家”时,链接没有发生任何事情,上面的错误将在控制台中出现。我正在使用1.5.7
用于angular.js和angular-route。