Note that there are some explanatory texts on larger screens.

plurals
  1. POAngular app does not load initial page
    primarykey
    data
    text
    <p>In an Angular app that I'm currently developing, the first page call does not cause the correct route template to be loaded (only the menu bar is shown). Only if I click on another link and back to the original, the correct page loads.</p> <p>Is there any known issue with first page loads or what can I do to debug this one?</p> <p>A bit of context: I'm using Angularjs (v1.2.0-rc.2) and requirejs (and many more, but they should be irrelevant). I can't provide a minimal working example, as I have no idea what to remove and what now. I also had this problem not occurring for some pages for a while, but now (after some more development on other pages), these exhibit the same behaviour. Any pointer are appreciated...</p> <h2>Update</h2> <p>As requested, an example of the route configuration. They look all fairly similar; some static part and some ids.</p> <pre><code>mod.config(function ($routeProvider) { $routeProvider.when('/some/:id/route/to/somewhere', { controller: 'MyController', templateUrl: '/template/some.template.html' }); }); </code></pre> <h2>Update 2</h2> <p>After a bit of stepping through the Angular code, I found that during the initial handling of a new URL in this snippet from <code>angular.js</code>, no handler was registered to the event <code>$locationChangeSuccess</code>.</p> <pre><code>// update browser var changeCounter = 0; $rootScope.$watch(function $locationWatch() { var oldUrl = $browser.url(); var currentReplace = $location.$$replace; if (!changeCounter || oldUrl != $location.absUrl()) { changeCounter++; $rootScope.$evalAsync(function() { if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl). defaultPrevented) { $location.$$parse(oldUrl); } else { $browser.url($location.absUrl(), currentReplace); afterLocationChange(oldUrl); } }); } $location.$$replace = false; return changeCounter; }); return $location; function afterLocationChange(oldUrl) { $rootScope.$broadcast('$locationChangeSuccess', $location.absUrl(), oldUrl); } </code></pre> <p>Only after the processing of the first page load has happened, in <code>angular-route.js</code>, this line is executed <code>$rootScope.$on('$locationChangeSuccess', updateRoute);</code> (which I believe causes the routing to work and views to display correctly). Every subsequent change of URL works fine... Maybe this is due to the way I initialise angular. I use:</p> <pre><code>angular.element(document).ready(function() { angular.bootstrap(document, ['some', 'more', 'modules', 'ngRoute']); }); </code></pre> <p>I've also updated to v1.2.5, but with no effect to my problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload