Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$inject function handlers #337

Closed
joeljeske opened this issue Oct 10, 2016 · 3 comments
Closed

$inject function handlers #337

joeljeske opened this issue Oct 10, 2016 · 3 comments

Comments

@joeljeske
Copy link

It would be very useful for function handlers to be injected instead of called directly. Especially when the functions need to be used in a provider context, it makes using services awkward.

Usage Examples:
Usage in Permission defintion

PermPermissionStore
   .definePermission(name, 
      /* @ngInject */ function($myService, permissionName, transitionProperty) {
       ....
   });

Usage in State definition

permissions: {
  only: 'myPermission',
  redirectTo: /* @ngInject */ function($myService, transitionProperties, rejectedPromise) {
     ....
  }
}

To make backwards compatible, you could detect if the function is setup for strictDi (either being an array with trailing function value, or a function with a $inject property) and either invoke directly or through the $injector. This would just enforce that injected functions must be strictly invoked.

@masterspambot
Copy link
Collaborator

@joeljeske Could you make a PR?

@joeljeske
Copy link
Author

Sure, just confirming it aligned with your interests.

joeljeske pushed a commit to joeljeske/angular-permission that referenced this issue Oct 12, 2016
joeljeske pushed a commit to joeljeske/angular-permission that referenced this issue Oct 12, 2016
masterspambot added a commit that referenced this issue Oct 19, 2016
@masterspambot
Copy link
Collaborator

Released in v4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants