Reputation: 372
I have this line at the code:
<a href="/blabla/topQues.html#{{m}}"data-ng-click="$event.preventDefault(); getQues()"></a>
The function getQues() pars the URL and do somthing, But the getQues() call befre the URL really changed.
What can i do to solve it?
Upvotes: 0
Views: 477
Reputation: 1634
Change your html a bit, pass the URL as a parameter to your getQues() function. Do
Do the parsing and other work in your function, then go to the desired url using $location.path("url")
If you want to keep the href attribute in the html tag, use ng-href instead of href
<a ng-href="/blabla/topQues.html#{{m}}" data-ng-click="$event.preventDefault(); getQues()"></a>
Upvotes: 0
Reputation: 1006
Use this:
$scope.$on('$routeChangeSuccess', function () {
var url = $location.path();
$scope.getQues(); // you can pass url to this function
});
Upvotes: 1