问题描述
我想获得的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 ...
有人可以请协助
感谢
推荐答案
有一些误解:
- 您没有指定
用户界面视图
渲染陈述成 - 您配置的状态为命名视图,如果你需要并行多个用户界面视图(嵌套的观点始终是可能的),这使得只可意会
使用<格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 normal views
(for single views)Demo with named views
(for multi-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的路由器的角度应用无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!