Lib: https://github.com/angular-ui/ui-router
使用实例:
// Some state name examples
// stateName can be a single top-level name (must be unique).
$stateProvider.state("home", {});
// Or it can be a nested state name. This state is a child of the
// above "home" state.
$stateProvider.state("home.newest", {});
// Nest states as deeply as needed.
$stateProvider.state("home.newest.abc.xyz.inception", {});
// state() returns $stateProvider, so you can chain state declarations.
$stateProvider
.state("home", {})
.state("about", {})
.state("contacts", {});
参数化配置:
var urls = ['news-1' ,'news-2', 'news-3'];
angular.forEach(urls, function(v) {
$stateProvider
.state(v, {
url: '/' + v,
views: {
'aboutBody': { templateUrl: templateBasePath + v }
}
});
});
若有疑问,请发表评论或添加微信为你解答:

本文介绍了一个强大的AngularJS路由库——ui-router的使用方法。通过示例展示了如何定义单级及多级状态,以及如何进行参数化配置。适用于希望深入了解ui-router特性的开发者。
5万+

被折叠的 条评论
为什么被折叠?



