這幾天看了angularjs和backbone,大看了解了knockout和emberjs,剛剛上網看到了一個angular的router的demo,現在順便記下來
route
//這個重要是做IE的兼容,發現不管用,IE坑爹,你懂的
Route Demo index
>
<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>