Okay, I've isolated the problem a bit further.  Everywhere I turn, it's 
something other than my original suspicion.

It looks like it's a directive population that's the real time hog here, 
not the http or JSON loading as I thought.  I've got something along these 
lines:

<div my-directive ng-repeat="item in category" 
some-text="{{item.TEXTFIELD}}"></div>

And my directive has a very basic template that just outputs the some-text 
item.

Originally, my directive had an isolate scope, so the some-text field was 
being copied, I assume?  I switched that to have scope: false, and the load 
time has been cut in about half.  BUT, It still feels really long, and I'm 
worried because this page is going to have a LOT more of these.

Is there any way to expedite this process?  These directives aren't 
initially visible within the page, so it would be great if there were some 
way to keep their loading from preventing the user from using the page.

I'm a little relieved that I narrowed down the problem, but I'm worried 
that this is a bottleneck that I can't get around.  I could delegate a lot 
of this stuff back into Coldfusion, but I'd love to not have to do that.

Any suggestions?



On Friday, September 12, 2014 12:17:27 AM UTC-7, Jonathan Price wrote:
>
> I have a page that has multiple instances of a given controller, all of 
> which need similar data.  Their instantiation looks sort of like this:
>
> <div ng-repeat="noteType in noteTypes" ng-controller="NoteController" 
> ng-init="init('note.noteTypeID')">
> blah blah blah
> </div>
>
> Initially, I had them all calling a service along these lines
>
>     .controller('NoteController', ['$scope', '$log', '$sce', 'Utility', 
> function($scope, $log, $sce, Utility){
>
>             Utility.getList().success(
>                 function(shortcutCategory) {
>                    ...init some stuff here...
>             });
>      }]);
>
> where the service calls an https request for some data.  Now that I'm 
> using multiples of this controller in the page, this seems dumb.  I'm 
> guessing the best way to do this would be to populate something in the 
> service itself with the 'getList' array, and just let the controllers 
> access that array.  Thus preventing the multiple, unnecessary calls. 
>
> Two Questions:
>
> 1) First one is about timing.  The controllers really need that data to be 
> available before some internal initialization.  I'm not sure how to handle 
> the timing of that.  Should the service broadcast an event after it loads 
> up the 'getList' data?
>
> 2)  Is my ng-init on the controller line an okay way to handle passing 
> instance specific data to each controller?
>
> Thanks!
>
>
>
>

-- 
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