tnajdek / angular-requirejs-seed

MIT License
1.03k stars 290 forks source link

Application Loader #44

Open ghost opened 8 years ago

ghost commented 8 years ago

I've build my app using your angular-requrejs-seed, now i need add loader because my app takes time to load first time is there any suggestion to add loader while requirejs loading all required files for app ?

tnajdek commented 8 years ago

Traditional approach would be to add a new css class to <body> (or a div container if you have one). Then that class would be removed once js, in this case angular, has loaded. You could then use that class to display a css spinner, here are some examples of single-element css spinners:

http://projects.lukehaas.me/css-loaders/

Hope this helps

ghost commented 8 years ago

Yeah i know that @tnajdek but problem is i cannot find angular.bootstrap(document, ['unation']); after event or onComplete event in the app.

tnajdek commented 8 years ago

You don't need that, you can just use ngCss, use a dedicated directive or put the logic in your index controller.

Try something like this

<div class="loading" ng-class="{'loaded': true}"></div>

then in css .loading for spinner .loading.loaded remove spinner.