I'm getting this error:
Property 'login' has no initializer and is not definitely assigned in the
constructor.ts(2564)
How can I solve this?
Below code of my component
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {Router} from '@angular/router';
import {UserService} from '../shared/service/user.service';
import {LoginRequest} from '../shared/model/login.request';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
public form: FormGroup;
public login: LoginRequest;
public error: boolean;
constructor(private router: Router, private userService: UserService) { }
ngOnInit(): void {
this.error = false;
this.login = new LoginRequest();
const fb = new FormBuilder();
this.form = fb.group({
user: [null, [Validators.required]],
newPassword: [null, [Validators.required, Validators.minLength(6)]]
});
}
get disableButtonOk(): boolean {
return this.form.invalid;
}
signing(): void {
this.userService.login(this.login)
.subscribe(
() => {
this.router.navigate(['/reset-password']);
},
() => this.error = true // TODO: tratar erro interno de servidor
);
}
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/7c1df3b8-d06b-4246-9e3c-c640cc49ba1dn%40googlegroups.com.