<!DOCTYPE html>
<html ng-app="ngView">
<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>
</head>
<body>
<p ng-view>
<p ng-controller="test">
</p>
</p>
<script type="text/javascript">
angular.module('ngView', [],
function($routeProvider){
$routeProvider.when('/test1',
{
templateUrl: 'demo.html',
controller: 'test'
}
)
.when('/test2',
{
templateUrl:'slinder.html',
controller: 'test'
}
);
}
);
</script>
</body>
</html>
挡在url中输出/#/test1时demo.html没有显示,请问是什么情况??
Tell me a few questions
1: ng-app is generally written in the body
2: When defining routes, it is best to write them in a $routeProvider
3: Your routing definition is wrong. You only write the template without specifying the controller, which is also the reason why it does not work.