Skip to main content
2 de 5
se añadieron 1293 caracteres en el cuerpo

Can't bind to 'ngModel' since it isn't a known property of 'input'

se que hay muchas preguntas de este tema , he navegado bastante y al momento no encontrado algo que lo solucione, agradeceria la ayuda que me puedan brindar

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>

El problema es que pese a que FormsModule ha sido importado sigue marcando el mismo error ,

Alguna sugerencia? , les agradezco de ante mano

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;
            });
}

}