我在按照书上学习路由的时候,完成的代码如下:
<!DOCTYPE html>
<html ng-app="myApp" lang="zh-cn">
<title>Simple app</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css"/>
</head>
<body >
<!-- HEADER AND NAVBAR -->
<header>
<nav class="navbar navbar-default">
<p class="container">
<p class="navbar-header">
<a class="navbar-brand" href="/">Angular Routing Example</a>
</p>
<ul class="nav navbar-nav navbar-right">
//这里引向不同的页面
<li><a href="#home"><i class="fa fa-home"></i> Home</a></li>
<li><a href="#login"><i class="fa fa-shield"></i> About</a></li>
</ul>
</p>
</nav>
</header>
<!-- MAIN CONTENT AND INJECTED VIEWS -->
<p id="main">
<!-- angular templating -->
<!-- this is where content will be injected -->
<p ng-view >//主要是这里
</p>
</p>
<script src="bower_components/angular/angular.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.0-beta.4/angular-route.min.js"></script>
<script src="app.js"></script>
</body>
</html>
<p ng-controller="HomeController">
<p>我是主页</p>
</p>
var app = angular.module('myApp',['ngRoute']);
app.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/home',{
templateUrl: 'page/home.html',
controller:'HomeController'
})
.when('/login',{
templateUrl: 'page/login.html',
controller:'LoginController'
}
);
}]);
结果是可以,但是控制台会报错,我想知道是什么原因?
오류 메시지를 보면
HomeController
문제가 정의되지 않은 것 같은데요?