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.

replace:true on a directive changes order of directive linking #1567

Closed
@mprobst

Description

@mprobst

See also this fiddle: http://jsfiddle.net/VhF7j/6/

var mod = angular.module('test', []);

mod.directive('testParent', function() {
    return {
        template: '<p ng-transclude></p>',
        transclude: true,
        // replace: true, // Enable to see the issue
        compile: function($tElement, $tAttr) {
            return {
                pre: function($scope, $element, $attr) {
                    console.log('parent link pre');
                },
                post: function($scope, $element, $attr) {
                    console.log('parent link post');
                }
            };
        }
    };
});

mod.directive('testChild', function() {
    return {
        link: function($scope, $element, $attr) {
            console.log('child link');
        }
    };
});


When a directive has 'replace:true', all its child directives are linked (post!) before its pre-link is evaluated. This makes it impossible to rely on passing information between directives through element.data and element.inheritedData.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions