[英]Nested routes in ui-router don't resolve
我试图在UI-Router内设置一个简单的嵌套视图,但由于某些原因这次我不想激活嵌套路由,因此我已经做了。
我的主home.html正常显示,并允许内容,但未显示任何嵌套视图。 我已经对照我的旧代码进行了检查,没有发现任何不同。
在我的HTML中
home.html
是通过ui-view
在index.html
呈现的
# Home.html
<p>Hello World<a ui-sref="hello">
<button>go hello</button></a>
<div ui-view></div>
</p>
# Hello.html
<p>Hello HTML</p>
在我的app.js中,我有以下路线:
angular.module('concierge.customer',
['ngCookies',
'ui.router',
'restangular'
])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/')
$stateProvider
.state('home', {
url: '/',
controller: function() {
console.log('Home Base')
},
templateUrl: 'modules/home/home.html'
})
.state('home.hello', {
url: '/hello',
controller: function() {
console.log('Home Hello')
},
templateUrl: 'modules/home/hello.html'
})
})
.run(['$rootScope', function($rootScope) {
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
console.log("You are going from ", fromState);
console.log('To: ', toState);
})
}])
如果我在地址栏中手动输入/hello
,我会得到
Error: Could not resolve 'hello' from state 'home'
这实际上是翡翠的一个已知问题
在第二个.state中,仅使用hello,而不使用home.hello,它应该会有所帮助。
这是pl子手,我在其中添加了两个链接Ahoy和Hello:
plnkr.co/edit/nautvr?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.