作者:键盘上的泪g_752 | 来源:互联网 | 2023-01-28 14:29
1> FierceDev..:
检查完电子邮件和发送邮件后,请尝试:
router.navigate(['/show_alunos'])
并在构造函数声明
constructor (private router: Router)
并从"@ angular/router"导入{Router};
更新:
简单示例如何使用Ruter:
your.component.html:
your.component.ts:
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from "@angular/forms";
import { Router } from "@angular/router";
@Component({
selector: 'component-tag-name',
templateUrl: './your.component.html'
})
export class YourComponentName implements OnInit {
myForm: FormGroup;
constructor(private router: Router) {}
ngOnInit(){
this.myForm = this.FormGroup({
'Email': new FormConrol(null, [Validators.required]),
'Password': new FormControl(null, [Validators.required])
})
}
onSubmit(){
let email = this.myForm.get('Email').value;
let password = this.myForm.get('Password').value;
if (email === 'your value' && password === 'your value'){
this.router.navigate(['/show_alunos']);
}
}
在yout app.module.ts中,您还需要导入此组件和ListAlunosComponent.然后你需要导入这个组件并写入你的路由配置.ts文件:
{ path: 'show_alunos', component: ListAlunosComponent }