lib/ngapp/tpl.helper.js
function registerListeners(scope, listeners) {
        var fns = [];

        for (var name in listeners) {
            if (listeners.hasOwnProperty(name) && listeners[name]) {
                fns.push(eventBus.on(name, $injector.invoke(listeners[name])));
            }
        }

        // make sure handlers are destroyed along with scope
        scope.$on('$destroy', function () {
            for (var i = 0; i < fns.length; i++) {
                fns[i]();
            }
        });
    }
function registerListeners(scope, listeners) {
        var fns = [];

        for (var name in listeners) {
            if (listeners.hasOwnProperty(name) && listeners[name]) {
                fns.push(eventBus.on(name, $injector.invoke(listeners[name])));
            }
        }

        // make sure handlers are destroyed along with scope
        scope.$on('$destroy', function () {
            for (var i = 0; i < fns.length; i++) {
                fns[i]();
            }
        });
    }
function registerListeners ( scope , listeners ) { var fns = [ ] ; for ( var name in listeners ) { if ( listeners . hasOwnProperty ( name ) && listeners [ name ] ) { fns . push ( eventBus . on ( name , $injector . invoke ( listeners [ name ] ) ) ) ; } } // make sure handlers are destroyed along with scope scope . $on ( '$destroy' , function ( ) { for ( var i = 0 ; i < fns . length ; i ++ ) { fns [ i ] ( ) ; } } ) ; }
Register listeners and make sure they will be destoryed once the scope
is destroyed.

@param scope
@param listeners
Register listeners and make sure they will be destoryed once the scope is destroyed .