1

I try to make correct view loading app.

HTML:

<body>
   <loading outerWidth='1000' outerHeight='1000' display='isReady'></loading>
   <div class='wrapper' ng-show='isReady'>
   </div>
</dody>

JS:

app.run(['$rootScope', '$state', '$stateParams', '$location', '$http', 'userData', function($rootScope, $state, $stateParams, $location, $http, userData) {
     $rootScope.isReady = false;
     $http.post('services/enter.php', {

     }).then(function(response) {
          $rootScope.isReady = true;
     });
 }]);

Basic idea: when app loading show some image/loading gif 'please wait'. Next post request to get data and after request show html. But I have problem to manipulate html from app.rum functiuon - I try use $rootScope. Need suggestions how I can do it better.

Darien Fawkes
  • 3,023
  • 7
  • 24
  • 35

2 Answers2

0
app.run()

is normally used to initialize your app. I would suggest you create a controller if you're going to keep manipulating your data inside html. In case the data is shared, avoid rootScope and instead use a service to share data across your app

0

Let this answer your question , $httpProvider.interceptors, to handle before and after send ajax request $http and broadcast it.

Community
  • 1
  • 1