這幾天看了angularjs和backbone,大看了解了knockout和emberjs,剛剛上網看到了一個angular的router的demo,現在順便記下來
<!---
DEMO_INDEX.html
-->
<!doctype html>
<head>
<meta charset="utf-8">
<title>route</title>
</head><br>//這個重要是做IE的兼容,發現不管用,IE坑爹,你懂的
<body ng-app="routeApp" class="ng-app:routeApp" id="routeApp">
<h1>Route Demo index</h1>
<script src="
>
<script src=">
<div ng-view></div>
<script src="http://localhost:81/js/angular.min.js"></script>
<script>
var routeApp = angular.module('routeApp',[]);
routeApp.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/list', {
templateUrl: 'list.html',
controller: 'RouteListCtl'
})
.when('/list/:id', {
templateUrl: 'detail.html',
controller: 'RouteDetailCtl'
})
.otherwise({
redirectTo: '/list'
});
}]);
//controller
routeApp.controller('RouteListCtl',function($scope) {
});
routeApp.controller('RouteDetailCtl',function($scope, $routeParams) {
$scope.id = $routeParams.id;
});
</script>
</body>
</html>