我使用的是AngularJS 1.5.8和ui路由器,我在左边有一个菜单,右边有一个内容区。
我想在不更新“内容”ui视图的情况下在菜单系统中导航,这可能吗?
在我的index.html中,我有两个ui视图
<div ui-view="menu"></div>
<div class="content" ui-view="content"></div>
然后,在我的设置路由文件中,我有以下内容;
settingsRoute = function($stateProvider, $urlRouterProvider){
$stateProvider
.state('settings', {
url: '/settings',
views: {
"menu": {templateUrl: 'templates/settings.html'}
}
})
.state('account', {
url: "/account",
views: {
"menu": {templateUrl: 'templates/settings.html'},
"content": {
templateUrl: 'templates/account.html',
controller: 'account'
}
}
});
$urlRouterProvider.otherwise('/account');
}
在我的成本路由文件中,我有
costingsRoute = function($stateProvider){
$stateProvider
.state('costings', {
url: '/costings',
views: {
"menu": {templateUrl: 'templates/costings.html'}
}
})
.state('invoices', {
url: '/invoices',
views: {
"menu": {templateUrl: 'templates/costings.html'},
"content": {
templateUrl: 'templates/invoices.html'
}
}
})
}
angular.module('app').config(costingsRoute);
例如,在下面的演示中,当它加载显示在内容中的帐户主体时,当我单击“成本”时,我希望仅更改菜单并离开内容视图,内容视图中的内容可以是“帐户主体”或“配置文件主体”。
发布于 2016-08-18 03:12:50
将此内容添加到您的成本计算视图...
https://plnkr.co/edit/Q2nXXWpSywkdEUKIUmC0?p=preview
.state('costings', {
url: '/costings',
views: {
"menu": {templateUrl: 'costings.html'},
"content": {
templateUrl: 'account.html'
}
}
})
https://stackoverflow.com/questions/39009367
复制相似问题