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.

element.data('$injector') returns undefined when manually bootstrapped and directive is on the same element #10556

Closed
@DrewML

Description

@DrewML

Howdy,

I discovered what I believe is an issue with the order of operations in which the $injector property is assigned to the top-level element in the application, which causes the reference to the $injector to be lost (preventing outside debugging tools from getting access).

In my application, I am manually bootstrapping. Additionally, I have a directive on the element I am passing into angular.bootstrap.

I believe the following lines are where the issue happens:

element.data('$injector', injector);
compile(element)(scope);

I believe that, immediately after the $injector is assigned to that DOM element, the compile() call is losing/dropping the reference in the .data() datastore. If I set a watch in Chrome's developer tools, I can see the object returned from .data() being wiped out half-way through the execution of the compile function.

This could be considered user error, but I didn't see any documentation specifying that this was an unacceptable use-case.

As a work-around, I have simply started passing the next parent element into angular.bootstrap, to prevent the compiling of the top-level directive from killing the reference I need to the injector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions