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.

module.decorator() requires explicit order of operations.  #12382

Closed
@bennadel

Description

@bennadel

All of the other module-level API methods - service, factory, run, config, etc - can execute in any arbitrary order. However, the new .decorator() method has to run after the target service is defined. This is because the feature has been merely piped into the $provide.decorator() method, which used to be required to run in the configuration phase, after all services have been defined. Now that it can be called at any time, the necessary $get() method doesn't always exist.

As such, this fails:

angular.module( "Foo" ).decorator( "greet", fn ); // error, greetProvider cannot be found.
angular.module( "Foo" ).service( "greet", fn );

... but this works:

angular.module( "Foo" ).service( "greet", fn );
angular.module( "Foo" ).decorator( "greet", fn );

If you could just queue up the .decorator() calls and run them as the first part of the config-queue-flush, I think this would solve the dependency on order-of-operations.

I don't know much about contributing to Angular, so in the future, hopefully I can submit this as part of a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions