Lady Rainicorn Lady Rainicorn - 1 year ago 155
AngularJS Question

Angularjs slow to load templates

I have some which doesn't really do much, still it does really take the longest time to load. I have written the code down for you all to see:

app.js

var simple = "simple test";
angular.module('CRTapp', []).controller('ItemController', function() {
this.item = simple;
});


index.html

<div id="item" ng-controller="ItemController as item">
{{item.simple}}
</div>


Sometimes people are having to wait nearly a second to see:

{{item.simple}}


before

simple test


appears but this is a very long time for some of you to have to wait. Waiting is ok for me but sometimes Jake gets impatient so I can make the HTML page load slowly if you like, but I do not want my Mr Stretchy to become sad when he sees a template before his own special website for his adventures in the Candy Kingdom.

Answer Source

This delay is the time angular library gets to parse your html. You can use ng-bind instead:

<div id="item" 
     ng-controller="ItemController as item"
     ng-bind="item.simple">
</div>

This way, your page don't get poluted while angular loads its content.