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.

$provide.value() to support functions #12365

Closed
@langdonx

Description

@langdonx

I came across this in the ngDoc comments:

 *   $provide.value('halfOf', function(value) {
 *     return value / 2;
 *   });

But it doesn't seem to be implemented? I'm not entirely sure how it would accept the value argument anyway, but I wanted it specifically to provide my controllers with a non-singleton value to aid (what I think is tremendously) in unit testing by providing a new value to each component that requests the dependency.

Edit: I've made the necessary changes by keeping track of the provider type in providerCache and modifying createInternalInjector::invoke to get the result of the function if the provider type is 'value'. It seemed almost too easily and makes me think there's a reason this wasn't implemented already. Is there something I'm not aware of?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions