微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angularjs – 使用UI-Router使用多个视图的空白页面

我跟着这个 articleother我试图复制维基上的内容,没有任何运气.

到目前为止,这就是我所做的
文件夹结构:

>偏

>指数

> index.html //内部视图
> index.css
> index.js // controller

>页脚

> footer.html
> footer.js

>标题

> //相同的结构

> index.html //主文件

stateProvider:

angular.module('app').config(function($stateProvider,$urlRouterProvider) {
        $stateProvider.state("index",{
            url: "/index",templateUrl:'/partial/index.html',views: {
                'footer@index': {
                    templateUrl: "/partial/header.html",controller:"FooterCtrl"
                },'header@index': {
                    templateUrl: "/partial/header.html",controller: "HeaderCtrl"
                }
            }
    });  
 $urlRouterProvider.otherwise('/index');

编辑:

这是标记

<div>
    <div id="content" class="container">

        <div ui-view="header"></div>
        <div ui-view></div>
        <div ui-view="footer"></div>

    </div>
  </div>

我正在浏览的网址是:localhost:9001 /#/ index

我没有任何错误只是一个空白页面

解决方法

看起来您在templateUrl上使用了不正确的路径.

这是使用ui-router:http://plnkr.co/edit/Nqwlkq1vGh5VTBid4sMv?p=preview的plunker

我还建议阅读http://angular-ui.github.io/ui-router/sample/#/的源代码,它在这里一个抽象的实现,以及关于如何正确使用ui-router的许多评论.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐