Hi Sander, thanks for the suggestion.  I haven’t tried it yet as I’ve found my 
problem is something a bit different that I originally thought.  It seems the 
bottleneck on loading this page is the size of a one http return - it’s coming 
back with 100 or so items, all of which have a text component of a few 
sentences.  I wouldn’t think that a huge payload, but it’s definitely adding a 
few seconds to load time.  I tried returning it without the text portion of 
each element, and it’s STILL adding a few seconds - which I’m having a hard 
time understanding.

Should a payload of that size (100-200 elements, each with two fields that are 
just integers) really add seconds to the load time?  That isn’t really that 
large is it?

I think my original idea (the solution to which you’ve posted) wouldn’t really 
help if this truly is the problem, no?

Also.  This is a component of a Coldfusion site that I’m trying to update with 
more front-end functionality.  So, I figured I could just bring the payload 
down with the initial request and populate the Controllers from that using the 
ng-init function.  But that’s not working either.  Looks something like this:

<div ng-controller=“MyController” ng-init=“init(preLoadedPayload)”>
        <div ng-repeat=“piece in payload”>stuff</div>
</div>

.contoller(‘MyController’),  ['$scope', function($scope){
        $scope.payload = [];
        $scope.settings = [];

        $scope.init = function(backendPayload) {
            $scope.payload = backendPayload;

            for (var i = 0; i < $scope.payload.length; i++) {
                $scope.settings[i] = 0;
            };
        }
}])

Which I though would work, but I’m getting a ‘$scope.payload not defined’ error 
in the init function.  I don’t understand.  

Does this seem like a reasonable approach?  I’m feeling pretty lost about how 
to move forward.

All suggestions welcomed and greatly appreciated.



On Sep 12, 2014, at 11:31 PM, Sander Elias <[email protected]> wrote:

> Hi Jonathan,
> 
> Yes, if that is working, it’s indeed mostly luck. This is where you need to 
> build your own promise handler.
> Something like this:
> 
>     .factory('Utility', function($http) { 
>         var self = this;
>         self.aList =  []; //placeholder
> 
>         self.reAssign = function (response) { //handle putting results into 
> the placeholder
>                  // don't forget to handle error's in here!
>                  self.aList = response.data;
>             };
> 
>         // a function to enable refetching. it also uses the promise to 
> (re)populate the aList array.
>         self.reftech= function () {self.pList = 
> $http.get('getList.html').then(self.reAssign);}
> 
>         // kick off first time loading!
>         self.refetch();
>         return self;
>      });
> This will always return the promise, and the complete list. But it will only 
> fetch only once, after that, it will just return the resolved promise.
> Doing this, you have the means to check if the list is fetched already (the 
> promise will be resolved/rejected), and the list itself readily
> Available. This is similar to what ngResource does.
> 
> With kind regards
> Sander
> 
> ​
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "AngularJS" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/angular/r-TxMo1bj14/unsubscribe.
> To unsubscribe from this group and all its topics, 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.

Reply via email to