Angular : Manual redirect to route

后端 未结 8 1165
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 19:50

I just recently started using angular 4 instead of angular.js 1.

I have followed the heroes tutorial to learn about the fundamentals of angular 4 and I am currently

8条回答
  •  攒了一身酷
    2020-12-12 20:39

    Angular Redirection manually: Import @angular/router, Inject in constructor() then call this.router.navigate().

    import {Router} from '@angular/router';
    ... 
    ...
    
    constructor(private router: Router) {
      ...
    }
    
    onSubmit() {
      ...
      this.router.navigate(['/profile']); 
    }
    

提交回复
热议问题