【发布时间】:2015-02-12 12:49:16
【问题描述】:
我在 Angular 应用程序中使用 ui-router,在绝大多数情况下它都没有问题。
$state.go("my-state") 不触发立即转换的情况很困难。有时它只是非常慢(几秒钟后转换到“我的状态”)有时它不会触发,直到我移动鼠标一段时间并触发一些事件处理程序(绝对与事件处理程序无关触发了过渡)。
这是我的指令中的内容:
// [...]
link: funtcion(scope, elm, attrs){
elm.on('mouseenter', function(){
// ...
})
.on('mousemove', function($event){
// ...
})
.on('mouseleave', function(){
// ...
})
.on('change', function(){
// ...
})
.on('click', (e) ->
if(someCondition){
e.preventDefault()
e.stopImmediatePropagation()
e.stopPropagation()
if(user.level == "visitor"){
$rootScope.$broadcast('showLogin')
}
else if(user.level == "member")
$('#elementId').remove()
// PROBLEM HERE:
$state.go("my-state")
}
else if(anotherCondition){
$('#elementId').remove()
}
)
}
// [...]
我错过了什么吗?
我可以做些什么来“强制” ui-router 开始转换?
【问题讨论】:
-
$('#eementId')点击后是不是直接去掉了? -
是的,但它不是指令附加到的元素,它是另一个元素
标签: javascript jquery angularjs angularjs-directive angular-ui-router