Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I redirect to another view-model in Aurelia JS?

Tags:

aurelia

I'm writing an application using Aurelia JS. How can I redirect to another URL? Is there a way to do it without creating a whole new navigation pipeline step?

Thanks

like image 499
Sunjay Varma Avatar asked Mar 02 '15 03:03

Sunjay Varma


1 Answers

to do that inject the router in the ViewModel and use the method navigate(route)

here is an example:

import {Router} from 'aurelia-router';  export class MyVM {    static inject() { return [Router]; }    constructor(router){     this.router = router;   }    someMethod(){     this.router.navigate("myroute");   } } 
like image 145
Daniel Camarda Avatar answered Oct 01 '22 12:10

Daniel Camarda