Javascript 角度ui路由器嵌套ui视图不工作
我试图在angular中创建一个简单的嵌套管线,每当出现嵌套管线时,视图都不会弹出 路径为Javascript 角度ui路由器嵌套ui视图不工作,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我试图在angular中创建一个简单的嵌套管线,每当出现嵌套管线时,视图都不会弹出 路径为http://localhost:9000/#/home/hello我仍然只看到homeHello 为什么嵌套的ui视图没有拾取home.hello模板 呈现HTML 意见 你好 你好 有一个示例。我改变的是:“扩展父模板” 为了展示我们如何瞄准第一个ui-view=“ui-view”,它实际上被命名为,有一个新的状态Hello2: .state('home.hello2', { url: '/hel
http://localhost:9000/#/home/hello
我仍然只看到homeHello
为什么嵌套的ui视图没有拾取home.hello模板
呈现HTML
意见
你好
你好
有一个示例。我改变的是:“扩展父模板”
为了展示我们如何瞄准第一个ui-view=“ui-view”
,它实际上被命名为,有一个新的状态Hello2:
.state('home.hello2', {
url: '/hello2',
views : {
'ui-view' : {
templateUrl: 'tpl.hello2.html',
}
}
})
而这个状态现在实际上是针对命名的ui view=“ui view
,因为它使用显式views{}
定义。另一方面,状态hello使用隐式视图定义,可以这样表示:
views : {
'' : { // targeting unnamed ui-view=""
templateUrl: 'tpl.hello2.html',
}
}
选中它您的子状态上的ui sref应该包括父状态。例如,
ui sref=“home.hello”
AFAIKIt不需要这样做。这是相对路径。即使在那里,它也不起作用
<!-- home/home`.html -->
<section class="home">home<a ui-sref=".hello">Hello</a>
<div ui-view="ui-view"></div>
</section>
<!-- home/hello.html -->
<section class="hello">Hello</section>
<section class="home">home
<a ui-sref=".hello">Hello</a>
<div ui-view="ui-view"></div>
<div ui-view=""></div> <!-- new line -->
</section>
.state('home.hello', {
url: '/hello',
templateUrl: 'tpl.hello.html',
})
.state('home.hello2', {
url: '/hello2',
views : {
'ui-view' : {
templateUrl: 'tpl.hello2.html',
}
}
})
views : {
'' : { // targeting unnamed ui-view=""
templateUrl: 'tpl.hello2.html',
}
}