Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

for e.g in my angular app

app.config(function($routeProvider, $locationProvider) {

   $locationProvider.hashPrefix('!');
   $routeProvider.when('/login', {
       templateUrl: '../login',
       controller: 'loginCtrl'
}).otherwise(...));

in this case my logictrl is in another js file. i want to include this when my path is /login. but this show loginCtrl is not a function.after some google i got loginCtrl js is not executed by ng-view.

how can i solve this. please help thankx in advance

share|improve this question
1  
generally you just add all other js files straight away in your index.html to avoid issues like this –  Jorg Jun 24 at 6:04
add comment

1 Answer

What you are looking for is called Lazy Loading. A google search should get you started, but here is the first link I found: http://www.slideshare.net/nirkaufman/angularjs-lazy-loading-techniques

Their technique is to use RequireJS.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.