首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS -UI-路由器不加载视图

AngularJS -UI-路由器不加载视图
EN

Stack Overflow用户
提问于 2016-05-03 17:35:43
回答 2查看 40关注 0票数 0

我在一个使用angular-route的应用程序中,我试图将ui-router集成到一个特定的模块中。在这个模块中,我没有包括angular-route

ui-sref urls都会生成很好的结果,但是当用户试图导航到视图时,它会返回到根。

angular-routeui-router能混在一起吗?

代码语言:javascript
复制
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'
            });
    }
  ]);

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-06-29 14:02:40

问题是在另一个模块中有一个流氓otherwise语句。

票数 0
EN

Stack Overflow用户

发布于 2016-05-03 17:37:16

在子状态中-“styleguide.sandbox”将URL从'/StyleGuide/Sandbox‘更改为'/Sandbox’。因为您已经提到过沙箱是样式向导的子类,所以路由器将自动将沙箱的URL处理为'/ styleguide / sandbox ',您不必特别提及它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37010747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档