From a92e76eaf962af9c1964d3d662da6856717271f8 Mon Sep 17 00:00:00 2001 From: Richard Casar Date: Sat, 16 Apr 2016 10:36:39 +0200 Subject: [PATCH] allow to pass attributes from parent component via ngOutlet directive --- src/ngOutlet.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ngOutlet.js b/src/ngOutlet.js index de603b4..569bf83 100644 --- a/src/ngOutlet.js +++ b/src/ngOutlet.js @@ -1,5 +1,5 @@ function createOutlet($q, $animate) { - function Outlet(router, scope, element, controller, $transclude) { + function Outlet(router, scope, element, controller, $transclude, attrs) { this.router = router; this.scope = scope; this.element = element; @@ -69,7 +69,14 @@ function createOutlet($q, $animate) { if (typeof componentName !== 'string') { throw new Error('Component is not a string for ' + instruction.urlPath); } - this.controller.$$template = '<' + dashCase(componentName) + ' $router="::$$router">'; this.controller.$$router = this.router.childRouter(instruction.componentType); this.controller.$$outlet = this; @@ -115,7 +122,7 @@ exports.ngOutletDirective = function($animate, $q, $rootRouter) { var parentCtrl = ctrls[0], myCtrl = ctrls[1], router = (parentCtrl && parentCtrl.$$router) || rootRouter; myCtrl.$$currentComponent = null; - router.registerPrimaryOutlet(new Outlet(router, scope, element, myCtrl, $transclude)); + router.registerPrimaryOutlet(new Outlet(router, scope, element, myCtrl, $transclude, attrs)); }, controller: function() {}, controllerAs: '$$ngOutlet' @@ -160,4 +167,4 @@ exports.routerTriggerDirective = function($q) { function dashCase(str) { return str.replace(/[A-Z]/g, function(match) { return '-' + match.toLowerCase(); }); -} \ No newline at end of file +}