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

Handling DI annotations in resolve #3387

Closed
1 of 3 tasks
Alexander3 opened this issue Mar 25, 2017 · 4 comments
Closed
1 of 3 tasks

Handling DI annotations in resolve #3387

Alexander3 opened this issue Mar 25, 2017 · 4 comments

Comments

@Alexander3
Copy link

This is a:

  • Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 0.4.2
and I'm using: "angular": "~1.5"

Bug Report

Current Behavior:

resolve state parameter can't handle dependency injection properly, it fails when code is minified.
This was extremely hard to debug. Generally I was trying to check if state params are present, like someone suggested here

Expected Behavior:

DI annotations should be handled consistently with the rest of angular. I am aware that this is probably bad usage of resolve , but if it allows DI it should handle all cases.

Link to Plunker that reproduces the issue:

https://plnkr.co/edit/RnLcUc5h6zbPvGjkIo0P?p=preview

@christopherthielen
Copy link
Contributor

No, you aren't using resolve correctly. Resolve is an object with keys and values.

Your example should read something like:

      resolve: { 
        somekey: ['$stateParams', '$location', function($stateParamsMinified, $location) {
         console.log("This won't work for minified arguments", $stateParamsMinified, $location.path());
        }] 
      }

@Alexander3
Copy link
Author

@christopherthielen Ok, but why this is working ?? It should give me warning or sth.

resolve: function($stateParams, $location) {
         console.log($stateParams, $location.path());
      }

@christopherthielen
Copy link
Contributor

it probably works because of a bug or something. it's been fixed in 1.0 branch. Yeah a warning might be nice for obviously invalid resolve: block. It's not high on my list, so PR welcomed

@Alexander3
Copy link
Author

@christopherthielen #3388

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

No branches or pull requests

2 participants