Navin Chinnasamy Navin Chinnasamy - 1 year ago 67
AngularJS Question

Get angularjs controller of current html page

How can I get the controller of the current page that is displayed on device? I just want to add a class named as controller name of that page. So that I can customize that page dynamically.

Answer Source

Do like this :$rootScope) {
    $rootScope.$on('$routeChangeSuccess', function(ev,data) {   
       if (data.$route && data.$route.controller)
    $rootScope.controller = data.$route.controller;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download