我正在尝试在 UI-Router 内部设置一个简单的嵌套 View ,我之前已经这样做过,但由于某种原因,这次嵌套路由不想被激活。
我的主 home.html 正常显示并允许内容,但不会出现任何嵌套 View 。我检查了我的旧代码,没有发现任何差异。
在我的 HTML 中
home.html
通过 index.html
中的 ui-view
呈现
# 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
,我会得到
错误:无法从状态“home”解析“hello”
最佳答案
这实际上是 Jade 的一个已知问题
关于javascript - ui-router 中的嵌套路由无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25211837/