[英]AngularJS - Multiple 'ui-sref' in single 'ui-sref-active'
[英]AngularJs - My ui-sref anchor tag can't be cancelled by event.preventDefault()
我有這個標簽:
<a ui-sref="MyModule">My Module</a>
當我單擊鏈接時,將執行以下操作:
$scope.$on("$locationChangeStart", function (event) {
if (!confirm('You have unsaved changes, continue?')) {
event.preventDefault();
}
});
但是我的視圖仍然會切換到MyModule接口。
嘗試使用此:
$scope.$on("$stateChangeStart", function (event) {
if (!confirm('You have unsaved changes, continue?')) {
event.preventDefault();
}
});
您正在使用UI-router
。 這是基於狀態的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.