我正在尝试在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'
这实际上是翡翠的一个已知问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句