Я создал новый проект с генератором mean.io.Файл TypeScript для компонента входа в систему имеет «app-login» для селектора, но файл HTML для компонента входа в систему нигде не содержит HTML-тега «app-login».
В предыдущих проектах я никогдане удалось поместить тег селектора в HTML-файл, поэтому я поместил все сгенерированное содержимое файла login.component.html в начальный и конечный HTML-теги app-login.
Теперь приложение создается толькохорошо, но он зависает, когда я пытаюсь перейти к представлению входа в систему.Может кто-нибудь сказать мне, почему это?
login.component.html:
<app-login>
<mat-card class="example-card">
<mat-card-header>
<mat-card-title>Login</mat-card-title>
</mat-card-header>
<mat-card-content>
<form class="example-form">
<table cellspacing="0">
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Email" [(ngModel)]="email" name="email" required>
</mat-form-field>
</td>
</tr>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Password" [(ngModel)]="password" type="password" name="password" required>
</mat-form-field>
</td>
</tr>
</table>
</form>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button (click)="login()" color="primary">Login</button>
<span>Don't have an account ? <a [routerLink]="['/auth/register']" >register</a> here</span>
</mat-card-actions>
</mat-card>
</app-login>
login.component.ts:
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import {AuthService} from '../auth.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['../auth.component.scss']
})
export class LoginComponent implements OnInit {
constructor(private authService: AuthService, private router: Router) { }
email: string;
password: string;
ngOnInit() {
}
login(): void {
this.authService.login(this.email, this.password)
.subscribe(data => {
this.router.navigate(['']);
})
}
}