app.config(function ($stateProvider, $urlRouterProvider, $httpProvider) {
$stateProvider.state('home', {
url: '/',
templateUrl: 'product/product.html',
controller: 'products'
}).state('productdetail', {
url: '/product/:productid',
templateUrl: 'product_details/productdetails.html',
resolve: {
Products: function($stateParams, Product) {
return Product.fetchList($stateParams.productid);
}
},
controller: 'productDetail'
}).state('category', {
url: '/category/:category_code',
templateUrl: 'category/category.html',
resolve: {
Categories: function($stateParams, Category) {
return Category.fetchList($stateParams.category_code);
}
},
controller: 'category'
}).state('category.product', {
// url: '/category/:category_code',
templateUrl: 'category/products.html',
// resolve: {
// Categories: function($stateParams, Category) {
// return Category.fetchList($stateParams.category_code);
// }
// },
// controller: 'category'
})
$urlRouterProvider.otherwise('/');
});
在我的控制器中我使用: $ state.transitionTo(' category.product') 这会先加载我的控制器两次,然后调用http://localhost:3000/category/cat_code 然后 http://localhost:3000/category