If you use ngRouter to load the data instead of the controller, as part of the routing process, you can use the resolve feature of the route description. That will delay loading the page until the promise resolves.
On the other hand, you could put a big "Loading ..." div on top of the regular page's HTML content (with absolute positioning and z-index and so on), and put an ng-if on that particular div which watches $scope.variable to be not "Hello" or some other isLoaded flag which you can set in the promise resolution. On Wed Nov 12 2014 at 4:16:13 AM <[email protected]> wrote: > Hi, > > On page load, I'm calling a controller, in which im getting data from HTTP > POST service mentioned below > > But as a result a page will be loaded and later after a while(1min) data > will be populated into the page. I want it to be avoided as wait until data > is arrived from the controller and then load the page. > > My code > HTML contents: > > <div id="scroller" data-ng-controller="myCtrl" data-ng-init="init()"> > <div ng-repeat="x in variable "> > <ul> > <li class="strong" >{{ x.shortMsg }}</li> > <li class="content">{{ x.validity }}<br /></li> > <li class="icon"><img src="{{ x.image }}"</li> > </ul> > </div> > > </div> > > Script contents: > > function myCtrl($scope, $window,$http) { > $scope.variable = "Hello"; > alert("calculaing data.. please wait"); > > $scope.init = function () { > > alert($scope.variable) > $http({ > method: 'POST', url: '/citibank/compressedDetails', > data: $scope.variable > }). > success(function(data, status, headers, config) { > // $window.location.replace('./confirm.html'); > $scope.variable=data; > // $scope.firstName=data; > }). > > }; > > } > > > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
