Wednesday, June 22, 2016

Quick AngularJS $location Tip

Usually we use the following line of code to navigate around within an AngularJS single page application:


This works fine most of the time, but depending on context, it might appear to do nothing. This is because the code only works within a digest loop. To ensure your navigation actually happens, wrap the call to path within a $timeout:

$timeout(function () {
© I caught you a delicious bass.
Back to top