$state.go('client').then(uiService.showAdminPanel);
我正在使用 ui.router 更改 AngularJS 中的状态。 uiService.showAdminPanel
是一个函数,它查找处于新状态的 DOM 元素 document.querySelector()
。
然而,它在<ui-view>
里面找不到任何东西。既不解决也不onSuccess()
功能。
我尝试在 setTimeout()
中执行此操作10毫秒内,效果很好。也许有人知道,延迟从何而来?
最佳答案
使用
$rootScope.$on("$stateChangeSuccess", function(event,toState, toParams, fromState, fromParams ){
//TODO AFTER STATE CHANGE SUCCESSFULLY
})
关于javascript - 无法在 $state.go 上捕获 DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49596455/