Monday, 16 May 2016

why Angularjs $anchorScroll and $location fails the first time and only work after second click


If you look your browser url, the url is changed after the first click and the webpage flickered.

That because after the url changed to xxxxx#anchor1, it re-rendered the web page.

To fix this we have to stop the re-render by putting this into your router: reloadOnSearch: false

Solution:

{
    route:'/',
    resolve: {
        templateUrl:'template.html',
        reloadOnSearch: false
    }
},

http://stackoverflow.com/questions/29526187/anchorscroll-and-location-only-work-after-second-try
http://stackoverflow.com/questions/21425378/supress-reloading-of-ui-router-based-view-on-query-parameter-change

No comments:

Post a comment