Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have AngularJs ui router in my application. I need to load js file based on my state.

.state('root.home',{
        url: '/index.html',
        views: {
            'header': {
                templateUrl: 'modules/header/html/header.html',
                controller: 'headerController'
            },          
            'content-area': {
                templateUrl: 'modules/home/html/home.html',
                controller: 'homeController'
            },
            'footer': {
                templateUrl: 'modules/common/html/footer.html',
                controller: 'footerController'
            }
        },
        data: {
            displayName: 'Home',
         }
    })

The headerController,homeController and footerController have different js files when the home state is loading at that time we need to load the controller js files Is it possible through the UI router?

share|improve this question
    
Are the js files angular or non angular? – Arjun U. Jun 8 at 15:19
    
angular js files – user3541485 Jun 9 at 11:43
    

I think you need to use a framework like RequireJs it is loading your Script files base on the page you are showing to the user

RequireJS loads all code relative to a baseUrl.

check it. I think It might be helpful.

share|improve this answer

ui-route is more powerful than requirejs (ng-route).

You may look her about differences:

Difference between angular-route and angular-ui-router

http://www.amasik.com/angularjs-ngroute-vs-ui-router/

share|improve this answer

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.