viewConfig undefined on viewContentLoadedd in ui-router

by Nelu Malancea

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.11/angular-ui-router.js"></script>
<div ng-app="myApp">
    <h1>Main view</h1>
    
    <p>ui-router view:</p>
    <div ui-view></div>
</div>

JavaScript

angular.module('myApp', ['ui.router'])

.config(function($stateProvider, $urlRouterProvider){

    $stateProvider
        .state('home', {
            url: '/home',
            template: '<p>This is home.</p>',
            controller: function($scope){
                console.log("this is the home view");
            }
        });

        $urlRouterProvider.otherwise("/home");
})

.run(function($rootScope){

    $rootScope
        .$on('$viewContentLoaded',
            function(event, viewConfig){ 
                // Q: Why is viewConfig undefined here?
                // I need to run some code only when certain view (e.g. with name="home") is loaded
                console.log(viewConfig);
        });
});