这几天看了angularjs和backbone,大看了解了knockout和emberjs,刚刚上网看到了一个angular的router的demo,现在顺便记下来
route
//这个重要是做IE的兼容,发现不管用,IE坑爹,你懂的
Route Demo index
">http://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2pre/html5shiv.js">>
">http://cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.js">>
">http://localhost:81/js/angular.min.js">>
<script><br />
var routeApp = angular.module('routeApp',[]);<br />
routeApp.config(['$routeProvider',function ($routeProvider) {<br />
$routeProvider<br />
.when('/list', {<br />
templateUrl: 'list.html',<br />
controller: 'RouteListCtl'<br />
})<br />
.when('/list/:id', {<br />
templateUrl: 'detail.html',<br />
controller: 'RouteDetailCtl'<br />
})<br />
.otherwise({<br />
redirectTo: '/list'<br />
});<br />
}]);<br />
//controller<br />
routeApp.controller('RouteListCtl',function($scope) {<br />
});<br />
routeApp.controller('RouteDetailCtl',function($scope, $routeParams) {<br />
$scope.id = $routeParams.id;<br />
});<br />
</script>