Se que hay muchas preguntas de este tema. He navegado bastante y al momento no encontrado algo que lo solucione.
El problema es que pese a que FormsModule
ha sido importado sigue marcando el mismo error.
AppModule.ts
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
....
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
....
Luego en html del template algo como esto:
<div class="ibox login-content">
<div class="text-center">
<span class="auth-head-icon"><i class="la la-user"></i></span>
</div>
<form class="ibox-body" id="login-form" action="javascript:;" method="POST">
<h4 class="font-strong text-center mb-5">LOG IN</h4>
<div class="form-group mb-4">
<input type="text" class="form-control-line" name="username" [(ngModel)]="model.username" required placeholder="Email"/>
</div>
</form>
loginComponent.ts
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { AlertService, AuthenticationService } from '../_services/index';
@Component({
moduleId: module.id,
templateUrl: 'login.component.html'
})
export class LoginComponent implements OnInit {
**model: any = {};**
loading = false;
returnUrl: string;
constructor(
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private alertService: AlertService) { }
ngOnInit() {
// reset login status
this.authenticationService.logout();
// get return url from route parameters or default to '/'
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
}
login() {
this.loading = true;
this.authenticationService.login(this.model.username, this.model.password)
.subscribe(
data => {
this.router.navigate([this.returnUrl]);
},
error => {
this.alertService.error(error);
this.loading = false;
});
}
}
Alguna sugerencia?
node_modules
, seguido denpm install
Si actualizaste a angular 10 desde angular < 9 tienes que actualizar las librerias a angular 10.