Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Controller from require is empty when using an explicit return #11147

Closed
@MerlierR

Description

@MerlierR

AngularJS v1.3.13

When a directive uses require: '^outer', the injected controller is {} in case an explicit return is used. (controller: function () { return ...; })

This issue does not occur in angular version 1.2.28

Example: http://jsfiddle.net/s6oyL2xk/

var app = angular.module('myApp',[]);

app.directive('outer', function () {
    return {
        restrict: 'E',
        template: '<div>Outer directive</div><div ng-transclude></div>',
        transclude: true,
        controller: function OuterController() {   
            return {
                data: 'outerController data'
            }
        }
    }
});

app.directive('inner', function () {
    return {
        restrict: 'E',
        template: '<div>Inner Directive</div><div ng-bind="test"></div>',
        require: '^outer',
        link: function (scope, element, attrs, outerController) {
            _.isEmpty(outerController) === true; // This should not happen
            scope.test = outerController.data;
        }
    }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions