Dani
Dani

Reputation: 4196

Change route in angular-meteor

I'm making an Angular 1 app but with TypeScript. I would like to change route in a function but I don't know how to do it:

// ...some lines skipped
import templateUrl from './foodSort.html';

class FoodSort {
  constructor($scope, $reactive, $location) {
    'ngInject';
    $reactive(this).attach($scope);

    var location = $location; // this doesn't work
  }

  changedUrl() {
    // HERE is where I want to change url
    location.path('food'); // this doesn't work
  }
}

const name = 'foodSort';

// create a module
export default angular.module(name, [
  angularMeteor
]).component(name, {
// ... some lines skipped

Upvotes: 0

Views: 77

Answers (1)

Urigo
Urigo

Reputation: 3185

If you are using ui-router then I think state.go is the way to go.

Here is another answer - https://stackoverflow.com/a/19362082/1426570

Upvotes: 1

Related Questions