问题与UI的路由器的角度应用无法正常工作 [英] issue with ui-router not working in the angular app

查看:95
本文介绍了问题与UI的路由器的角度应用无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的URL路由器我的应用程序,但由于某种原因,它不会链接文件的工作。
我创建了一个简单的plnkr来证明这个问题...

I am trying to get the URL router working for my app but for some reason it will not link the files. I have created a simple plnkr to demonstrate the issue ...

有人可以请协助

http://plnkr.co/edit/XQs2vP4vtqnBWGKqmJZz

感谢

推荐答案

有一些误解:


  1. 您没有指定用户界面视图渲染陈述成

  2. 您配置的状态为命名视图,如果你需要并行多个用户界面视图(嵌套的观点始终是可能的),这使得只可意会

使用<格UI的视图>< / DIV> 在视图中进行正常的意见,并使用<格UI视图= 内容>< / DIV> 的命名视图(内容是你可以随意选择一个自定义名称)

How to fix it

Use <div ui-view></div> in your views for normal views and use <div ui-view="content"></div> for named views (content is a custom name which you may choose at will).

此外,您还可以使用 UI-SREF 属性链接到这是更好的做法不是设置的href 手动。在所有的演示下面我展示两种方式。

Also, you can use the ui-sref attribute to link to specific states which is better practice than setting the href manually. In all demos below i showed both ways.

请注意,正常的意见有一个简单的状态定义语法:

Note that normal views have a simpler state definition syntax:

.state('person', {
    url: '/persons',
    templateUrl: 'list1.html',
    controller: 'employeeCtrl'
})

演示

演示与正常的意见 (单视图)

演示与命名视图 (用于多视图)

在这两种情况下,你可以嵌套意见UI路由器的possibilites的进一步探索(这使得它的方式优于默认路由角):

Demos

Demo with normal views (for single views)

Demo with named views (for multi-views)

In both cases you can nest views as a further exploration of the possibilites of ui-router (which makes it way superior to default angular routing):

无限可能。

这篇关于问题与UI的路由器的角度应用无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆