I have the next problem.
I have different behaviours of <a> elements. I have a controller which handle 2 events:
$scope.$on("$destroy", function () {
console.log("$destroy");
});
$scope.$on("$locationChangeStart", function () {
console.log("$locationChangeStart");
});
Sometimes $locationChangeStart event fired first, but sometimes $destroy event fired first.
I need to prevent changing page, so I need $locationChangeStart to be fired first.
Please, someone has any thoughts, why different <a> have different sequence of events?
UPD
I use the same <a> element in different parts of page
<a href="#/overview">test</a>
If you want to prevent changing page it doesn't matter which one is launch first.
In your $locationChangeStart add the event object:
$scope.$on("$locationChangeStart", function (event) {
event.preventDefault(); // will prevent the location change
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With