简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM