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

$state and $location undefined ... need programmatic way to change URL for routing #162

Open
ghost opened this issue May 3, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented May 3, 2016

When a button is pressed, I need to authenticate the user before setting the URL allowing the user to route to the next page. Thus I can't use ui-sref. I tried $location.Path and $state.go and neither is defined.

import { $state } from 'ng-forward'; is undefined...
thus subsequent @Inject or $state.go("/homePage"); will fail.

What alternative would you suggest ... hopefully not javascript force a new URL.

Thanks,
Chuck Duncan
Camp Systems, Merrimack, NH

@j-walker23
Copy link

j-walker23 commented May 8, 2016

Sorry if i don't understand your question. But this might be what you are looking for.

import { Inject, Component } from 'ng-forward'
import { IStateService } from 'angular-ui-router'
type ILocationService = angular.ILocationService

/**
 * @author john
 * @version 4/8/116
 */


@Component({
  selector: 'some-comp',
  template: ``
})
@Inject('$state', '$location')
export class SomeComponent {

  constructor (private $state: IStateService, private $location: ILocationService) {

    this.$state.go('some-state')
    // or
    this.$location.url('/homePage')
  }

}

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

1 participant