我在一个使用angular-route的应用程序中,我试图将ui-router集成到一个特定的模块中。在这个模块中,我没有包括angular-route。
ui-sref urls都会生成很好的结果,但是当用户试图导航到视图时,它会返回到根。
angular-route和ui-router能混在一起吗?
angular.module('StyleGuide', ['ui.router'])
.config(['$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/StyleGuide/');
// Configure UI-Router
$stateProvider
.state('styleguide', {
url: '/StyleGuide/',
templateUrl: 'App/StyleGuide/styleguide.html'
})
.state('styleguide.sandbox', {
url: '/StyleGuide/Sandbox',
templateUrl: 'App/StyleGuide/sandbox/sandbox.html',
controller: 'SandboxController'
});
}
]);<div class="sgHeader">
<div class="navbar navbar-default">
<nav class="container-fluid">
<ul class="nav navbar-nav">
<li class="dropdown open" uib-dropdown >
<a role="button" class="dropdown-toggle" uib-dropdown-toggle aria-haspopup="true" aria-expanded="true">
<i class="fa fa-bars"></i>
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="simple-dropdown">
<li><a ui-sref="styleguide.sandbox"><i class="fa fa-hourglass-start"></i>Sandbox</a></li>
</ul>
</li>
</ul>
<div class="navbar-header">
<a class="navbar-brand" ui-sref="styleguide"><span class="heavy">Soar </span>Styleguide</a>
</div>
</nav>
</div>
</div>
<div class="sg__body" ui-view>
<div style="text-align: center;">
<h1>The Soar Style Guide, this is.</h1>
<h3>Use it to promote codebase and visual consistency, you will.</h3>
<img src="https://s-media-cache-ak0.pinimg.com/originals/49/7d/80/497d80f923e70aaa558d17c9cd1ee142.gif" />
</div>
</div>发布于 2016-06-29 14:02:40
问题是在另一个模块中有一个流氓otherwise语句。
发布于 2016-05-03 17:37:16
在子状态中-“styleguide.sandbox”将URL从'/StyleGuide/Sandbox‘更改为'/Sandbox’。因为您已经提到过沙箱是样式向导的子类,所以路由器将自动将沙箱的URL处理为'/ styleguide / sandbox ',您不必特别提及它。
https://stackoverflow.com/questions/37010747
复制相似问题