FWIW - I was able to successfully accomplish this by following this blog 
post:

http://ify.io/lazy-loading-in-angularjs/


On Tuesday, April 8, 2014 9:39:10 PM UTC-4, Marten Liebster wrote:
>
> Do you know if there are any plans to incorporate this?
>
> I'm looking to develop a site with quite a few data driven pages. 
> Conceptually it seems more effecient to only load the controllers needed at 
> the time. 
>
>
> On Monday, March 4, 2013 2:32:25 AM UTC-5, Josh David Miller wrote:
>>
>> As of the current version of AngularJS there is no way to lazy load code. 
>>
>> But it's usually not needed. Because the templates are in the DOM, the 
>> fantastic data bindings, and a host of other reasons, AngularJS projects 
>> tend to be *much* smaller than projects in other frameworks. Unless you're 
>> building an absolutely massive application, this probably isn't necessary.
>>
>> That said, your code doesn't need to be in your index.html file - it just 
>> needs to be loaded before your app runs so the $injector knows where to 
>> find things. So feel free to put the controller in a separate file (this is 
>> standard practice anyway) and either concat and minify your files together 
>> and include your "app.js" file into your index.html, or include each source 
>> file in its own script tag in index.html. If you need help getting started 
>> with this kind of AngularJS development, check out angular-seed (
>> https://github.com/angular/angular-seed) or ngBoilerplate (
>> http://bit.ly/ngBoilerplate). Also take a look at angular-app (
>> https://github.com/angular-app/angular-app/) to see what a typical 
>> non-trivial AngularJS app looks like, from back to front.
>>
>> Hope this helps.
>>
>> Josh
>>
>>
>> On Sun, Mar 3, 2013 at 11:15 PM, Rentius Engelbrecht <
>> [email protected]> wrote:
>>
>>> Hi Josh
>>>
>>> I have the index.html file which I use to load the partial pages into.
>>> But the controller to use depends on the page that I'm loading. A lazy 
>>> loading scenario for each js file.
>>>
>>> When loading videos partial html into the app I want to use 
>>> videosContoller.js.
>>> I do not want to include the controller in the main html file because as 
>>> my app grows so does the code in the file and I want to separate the code 
>>> out to load when the specific page loads.
>>>
>>> Regards
>>>
>>> On Monday, March 4, 2013 9:05:06 AM UTC+2, Joshua Miller wrote:
>>>
>>>> Hello!
>>>>
>>>> No, the `controller` property must either be a function or a string 
>>>> representing a registered function. So you can do `controller: 
>>>> VideoListCtrl` or you can to `controller: 'VideoListCtrl'`, where the 
>>>> controller was registered: `myApp.controller( 'VideoListCtrl', function 
>>>> ($scope) { ... });`.
>>>>
>>>> Why do you want to specify a file name?
>>>>
>>>> Josh
>>>>
>>>>
>>>> On Sun, Mar 3, 2013 at 10:33 PM, Rentius Engelbrecht <
>>>> [email protected]> wrote:
>>>>
>>>>> Is it possible to specify a controller.js file to use for a certain 
>>>>> url in the route?
>>>>> Example:
>>>>>
>>>>>
>>>>>    1. $routeProvider.when('/videos', {templateUrl: 
>>>>>    'partials/video-list.html', controller: videosController.js}) 
>>>>>
>>>>>
>>>>> Instead of:
>>>>>
>>>>>
>>>>>    1. $routeProvider.when('/videos', {templateUrl: 
>>>>>    'partials/video-list.html', controller: VideoListCtrl}) 
>>>>>
>>>>>
>>>>>
>>>>> Regards
>>>>>
>>>>> -- 
>>>>> 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?hl=en-US.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>  
>>>>>  
>>>>>
>>>>
>>>>  -- 
>>> 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?hl=en-US.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>

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