Javascript AngularJS ui路由器:我已经将param发送到$state.go()的嵌套状态,但什么都没有发生
我有一个这样的状态Javascript AngularJS ui路由器:我已经将param发送到$state.go()的嵌套状态,但什么都没有发生,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我有一个这样的状态 .state('topic.content', { url: '/:id', resolve: { topicContent: ($stateParams, TopicService) => { return TopicService.getContent({ topicId: $stateParams.id }).$promise } }, controller: 'topicCt
.state('topic.content', {
url: '/:id',
resolve: {
topicContent: ($stateParams, TopicService) => {
return TopicService.getContent({ topicId: $stateParams.id }).$promise
}
},
controller: 'topicCtrl',
templateUrl: 'partials/topic.html',
})
我正试图用这个代码进入这个状态
$state.go('topic.content', { 'id': res.id })
res.id为“58ba84164e1af51e2c19aa1d”,长度为24个字符
但我的控制台中没有发生任何事情,也没有错误。接下来,我尝试了下面所有的方法
$state.go('topic.content', {id:'58ba84164e1af51e2c19aa1d'})
// or
let params = { id: '58ba84164e1af51e2c19aa1d' }
$state.go('topic.content', params)
$state.go('topic.content', {id:'1234567890'})
// or
$state.go('topic.content', {id:'123456789012345678901234'}) // 24 length :)
// or
$state.go('topic.content', {id:'abcd567890abcd5678901234'})
所有这些都没有区别。但在下面
$state.go('topic.content', {id:'58ba84164e1af51e2c19aa1d'})
// or
let params = { id: '58ba84164e1af51e2c19aa1d' }
$state.go('topic.content', params)
$state.go('topic.content', {id:'1234567890'})
// or
$state.go('topic.content', {id:'123456789012345678901234'}) // 24 length :)
// or
$state.go('topic.content', {id:'abcd567890abcd5678901234'})
所有这些都是成功的,可以更改为topic.content状态
那么,我做错了什么?非常感谢初学者
PS:如果你明白我的意思,对不起我的英语。TopicService.getContent是否可能只接受十六进制值?是的,先生。它只需要主题的id(十六进制)。谢谢。您的问题可能在resolve回调中,因为您没有错误,也没有发生任何事情。尝试调试以查看解析器中
id
的值,并确保您的服务实际到达了REST。