question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Comparability problem in $state.get(toState.name).getState() with ui-router-extras

See original GitHub issue

Was anyone successful at using angular permission together with ui-router-extras ( https://github.com/christopherthielen/ui-router-extras )?

I get an exception during angular-permission initialization “TypeError: $state.get(…).getState is not a function” after declaring the dependency on ‘ct.ui.router.extras’ in here:

compensatePermissionMap(statePermissionMap) {
        var permissionMap = new PermissionMap({redirectTo: statePermissionMap.redirectTo});

        var toStatePath = $state
          .get(toState.name) 
          .getState().path // !!! error here
          .slice()
          .reverse();
...

It happens for toState.name == ‘login’, my route declaration is following:

# CoffeeScript
angular.module 'myModule'
.config ($stateProvider) ->
  $stateProvider
  .state "loginModule",
    abstract: true
    template: "<ui-view/>"
    data:
      permissions:
        only: ['guest']
        redirectTo: 'dashboard'

  .state "login",
    parent: "loginModule"
    url: "/login"
    templateUrl: "login.html"
    controller: "LoginCtrl"

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Paragonidcommented, Mar 10, 2016

Yes, thank you guys, switching these lines in module dependency fixes it:

angular.module('module', [
  'ui.router'
  'permission' # error
  'ct.ui.router.extras'
])
angular.module('module', [
  'ui.router'
  'ct.ui.router.extras'
  'permission' # no error
])
1reaction
masterspambotcommented, Mar 9, 2016

Oh boy! I’m gonna fix that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular ui-router: get $state info of toState in resolve
I would like to access the state's name and other attributes the app is navigating to using angular ui-router when working on the...
Read more >
ui-router extras 0.0.15-pre2 - gists · GitHub
// should create a ui-router state. // The factory function is injected/executed using the runtime $injector. The future-state is injected as 'futureState'.
Read more >
Using ui-router to handle states and views for Angular ...
Get the DSR key for this state by calculating the DSRParams option var cfg = getConfig(toState); var key = getParamsString(toParams, cfg.params); var ...
Read more >
angular-ui-router | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
State.stateservice - UI-Router
If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned. Parameters. fromPath PathNode[]. toState ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found