Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to let angularjs show fast part first, then render slow part?
    primarykey
    data
    text
    <p>I have a big angularjs html page, the rendering of angularjs will take a lot of time. So the page is almost blank at first, and after a while, it shows everything suddenly.</p> <p>I wonder if there is any way to make the fast part shows first, and the slow part will show later, so the user won't be surprised by a blank page.</p> <p>I made a simple demo:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html ng-app&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-controller="Ctrl"&gt; &lt;button ng-click="go()"&gt;Go&lt;/button&gt; &lt;hr/&gt; &lt;div&gt;Fast&lt;/div&gt; &lt;button ng-repeat="name in fastNames"&gt;{{name}}&lt;/button&gt; &lt;hr/&gt; &lt;div&gt;Slow&lt;/div&gt; &lt;button ng-repeat="name in slowNames"&gt;{{name}}&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; &lt;script type="text/javascript"&gt; function Ctrl($scope) { $scope.fastNames = []; $scope.slowNames = []; $scope.go = function () { $scope.fast(); $scope.slow(); } $scope.fast = function() { $scope.fastNames = ["F1", "F2"]; }; $scope.slow = function() { for (var i = 0; i &lt; 50000000; i++) { new Date(); } $scope.slowNames = ["S1", "S2"]; } } &lt;/script&gt; </code></pre> <p>You can see there are two parts -- "fast names" and "slow names". I hope the fast names can show as soon as possible, then the slow names. But for now, they won't show at first, and after a while, they show together.</p> <p>I created a live demo: <a href="http://plnkr.co/edit/9lW2TbLBkCB1hhgBVGmo?p=preview" rel="nofollow">http://plnkr.co/edit/9lW2TbLBkCB1hhgBVGmo?p=preview</a></p> <p>What should I do?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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