javascript - AngularJS - How to display message "Loading..." while the content is being loaded? -


i found threads topic on so, looks way of loading data isn't best.

this how controller looks like:

app.controller("postsctrl", ['$scope', '$http', '$resource', 'posts', 'post', '$location', '$modal', '$timeout', function($scope, $http, $resource, posts, post, $location, $modal, $timeout) {       $scope.posts = posts.query();      ... add/edit/delete code 

when page loaded, data db not displayed immediately. how display there loading... message?

i've tried using <div ng-if="loading">loading...</div> in view ,

$scope.loading = true; $scope.posts = posts.query(); $scope.loading = false; 

in angularjs controller, doesn't seems working. i've noticed $scope.posts = posts.query(); executed every time when there's call controller.

is (or angularjs) way solve matter?

thank in advance.

what about

$scope.loading = true; $scope.posts = posts.query(function ()  {     $scope.loading = false; }); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -