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

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -