giorgi goginashvili giorgi goginashvili - 1 year ago 79
AngularJS Question

How to define controller(s) for many templateUrl

I am using angular routes like

$routeProvider

.when('/problems/monthly/volume',{
templateUrl: 'frivolousTerminalsPersentByMonth.htm',
controller: 'mainController'

})


and so on .When i have many templateUrl and i am usinf one controller all of them , is it necessary to define
controller: 'mainController'
for all of them ? if no where is this one point where i can define it.

Answer Source

if you gave controller name in index.html file, then no need of mentioning controller name in $rootProvider. not even for single. you can write like this.

$routeProvider

    .when('/problems/monthly/volume',{
            templateUrl: 'frivolousTerminalsPersentByMonth.htm'

    })

    .when('/problems/monthly/volume1',{
            templateUrl: 'example.htm'

    })

   .when('/problems/monthly/volume2',{
            templateUrl: 'example2.htm'

    })
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download