ecmascript 6 - How call router navigate method from Angular 2? -


i use angular 2, systemjs , es6 (not typescript).

what want? want navigate link route. i'm doing

// route exam simple export let routes = [     {path: '', name: 'home', component: homecomponent, terminal: true},      {path: 'auth', name: 'auth', component: authcomponent} ] 

it works if use [routerlink]. , want programmatically use router this

    import { component } '@angular/core'; import { router, router_directives } '@angular/router';  @component({     selector: 'tf-main',     directives: [router_directives],     template: '<p>home</p><router-outlet></router-outlet>' })  export class homecomponent {      static parameters() {         return [[router]]     }      constructor(router) {         this.router = router;          // wrong way!!!! help!!!!         this.router.navigatebyurl(['auth']);     } } 

just

this.router.navigate(['auth']); 

or

this.router.navigate(['/auth']); 

(to ensure root route auth used)


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -