[英]angularjs ui.router
template didnt change to (shop.product state) when i going to '/someShop/someProduct' the template is still using the (shop state)当我转到“/someShop/someProduct”时,模板没有更改为(shop.product 状态),模板仍在使用(shop 状态)
/:shopid/:productid /:shopid/:productid
app = angular.module('LittleP', ['ui.tinymce','ui.router']);
app.config(function ($locationProvider,$stateProvider) {
$locationProvider.html5Mode(true);
$stateProvider
.state('index', {
url: '/',
templateUrl: 'LittleP/page/home/home.html',
controller: 'home'
})
.state('search',{
url: '/s',
templateUrl: 'LittleP/page/search/search.html',
controller: 'search'
})
.state('shop', { <--- this is the parent
url: '/:shopid',
template: 'LittleP/page/product/product.html',
controller: function ($scope,$stateParams) {
$scope.hello = 'this is shop';
}'
})
.state('shop.product', { <--- this is the childern
url: '/:productid',
template: '<h1>{{hello}}</h1>',
controller: function ($scope,$stateParams) {
$scope.hello = 'this is the product of ' + $stateParams.productid;
}
});
Try to do something like that:尝试做这样的事情:
app.config(['$stateProvider', '$locationProvider'],function ($stateProvider, $locationProvider) {
$stateProvider
.state('shop', {
abstract: true,
views: {
'content@': {
templateUrl:'LittleP/page/product/product.html',
controller: 'yourController',
}
},
})
.state('shop.product', {
url: '/:productid',
views: {
'shop@shop':{
templateUrl: yourUrlPath,
template: '<div>Children path</div>'. //this is agin templateUrl
controller: 'childController,
}
}
});
$locationProvider.html5Mode({
enabled: true,
requireBase: false,
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.