<!DOCTYPE html>
<html>
<head>
<title>分页显示</title>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
//<script src="js/angular.js"></script>
</head>
<body ng-app="ngView">
<p ng-view>
</p>
<script type="text/javascript">
angular.module('ngView', [],
function($routeProvider){
$routeProvider
.when('/',
{
templateUrl: 'demo.html'
}
)
.when('/test1',
{
templateUrl: 'demo.html'
}
)
.when('/test2',
{
templateUrl:'slindex.html'
}
);
}
);
</script>
</body>
</html>
透過cdn方式進行angular檔案引入時在火狐瀏覽器中可以實現,chrome不可以。透過本地文件進行angular引入時提示:
Uncaught Error: [$injector:modulerr] Failed to instantiate module ngView due to:
Error: [$injector:unpr] Unknown provider: $routeProvider
http://errors.angularjs.org/1.3.16/$injector/unpr?p0=%24routeProvider
at file:///C:/wamp/www/js/angular.js:63:12
at file:///C:/wamp/www/js/angular.js:4031:19
at getService (file:///C:/wamp/www/js/angular.js:4178:39)
at Object.invoke (file:///C:/wamp/www/js/angular.js:4210:13)
at runInvokeQueue (file:///C:/wamp/www/js/angular.js:4125:35)
at file:///C:/wamp/www/js/angular.js:4134:11
at forEach (file:///C:/wamp/www/js/angular.js:326:20)
at loadModules (file:///C:/wamp/www/js/angular.js:4115:5)
at createInjector (file:///C:/wamp/www/js/angular.js:4041:11)
at doBootstrap (file:///C:/wamp/www/js/angular.js:1455:20)
http://errors.angularjs.org/1.3.16/$injector/modulerr?p0=ngView&p1=Error %3A…otstrap%20(file%3A%2F%2F%2FC%3A%2Fwamp%2Fwww%2Fjs%2Fangular.js%3A1455%3A20)
你沒有引入angular-route