Sunday 21 August 2016

angularjs - Preload ng-view for smoother navigation



I'm using $location.path() to load new view inside my angular web site.
My page looks like :













And I change the ng-view depending on the demands (index, home, login, etc).
Some times the navigation seems slow (some glitch stay within the page while 0.1 secs) is there a way to make the navigation instant ?




Also, I tried the ng-animate which improved that feeling but not completely.
I guess that preloading my 'views' will be one solution ..



Edit :



Feeling improved by adding :



myApp.run(function ($templateCache, $http) {
$http.get('Template1.html', { cache: $templateCache });
});


Answer



Thanks to Baba. But I found a solution which does not involve to change my route (and use another library such as Angular UI Router (which is by the way super!))



My solution : preload my templates with the $templateCache and add animation (nice tuto : http://scotch.io/tutorials/javascript/animating-angularjs-apps-ngview + http://daneden.github.io/animate.css/)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...