Angular 2 - Como navegar para outra rota usando this.router.parent.navigate ('/ about')?
Angular 2 - Como navegar para outra rota usando this.router.parent.navigate ('/ about').
Parece não funcionar. Eu tentei location.go ("/ about"); como isso não funcionou.
basicamente, uma vez que um usuário está logado, quero redirecioná-lo para outra página.
Aqui está o meu código abaixo:
import {Component} from 'angular2/angular2';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';
import {Router} from 'angular2/router';
import {AuthService} from '../../authService';
//Model
class User {
constructor(public email: string, public password: string) {}
}
@Component({
templateUrl:'src/app/components/todo/todo.html',
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES]
})
export class Todo {
model = new User('[email protected]', 'Password');
authService:AuthService;
router: Router;
constructor(_router: Router, _authService: AuthService){
this.authService = _authService;
this.router = _router;
}
onLogin = () => {
this.authService.logUserIn(this.model).then((success) => {
//This is where its broke - below:
this.router.parent.navigate('/about');
});
}
}
Agradeço antecipadamente!