angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

How can I access PathNode, ResolveContext, RejectType and other inner vairables/classes in my angularjs application? #3489

Closed Maximaximum closed 4 years ago

Maximaximum commented 7 years ago

When I try to run this code in a controller, I get angular-ui-router.js:6683 ReferenceError: PathNode is not defined error. How can I access the PathNode constrctor from my application?

public uiOnParamsChanged(newParams, transition) {
  this.$stateParams = newParams;

  let toState = transition.to().$$state();
  let pathAsNodes = toState.path.map(x => new PathNode(x));
  let resolveContext = new ResolveContext(pathAsNodes);

  resolveContext.resolvePath().then((results: any[]) => {
    let obj = results.reduce((total, current) => { total[current.token] = current.value; return total; });
    this.update(obj);
  });
};
Maximaximum commented 7 years ago

I should add that I install 'angular-ui-router' v.1.0.4 package via bower.

Maximaximum commented 7 years ago

Here is a duplicate issue: https://github.com/angular-ui/ui-router/issues/3209

musakarakas commented 6 years ago

This worked for me. Maybe it'll help some webpack users:

import { RejectType } from "@uirouter/angularjs";

app.run($transitions =>
  $transitions.onError({}, transition =>
    console.log(transition.error().type === RejectType.ERROR)
  )
);
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.