I start in Angular, and I have an error that I can not solve on my application. I would like to check that my form is validated, that it is not empty. And if it is, the field would become red as with bootstrap.
Here is part of my code:
step-event.component.ts :
import { Component, OnInit, EventEmitter, Output } from '@angular/core';
import { ViewChild } from '@angular/core/src/metadata/di';
@Component({
selector: 'app-step-event',
templateUrl: './step-event.component.html',
styleUrls: ['./step-event.component.css']
})
export class StepEventComponent implements OnInit {
@Output() onNext = new EventEmitter<boolean>();
event = ''
constructor() { }
ngOnInit() {
}
nStep() {
if(this.event === ''){
console.log("nonono");
return;
}
console.log("event : OK");
this.onNext.emit(true);
}
}
step-event.component.html:
<input id="event" name="event" type="text" #event>
<button (click)="nStep()">OK</button>
what I get with this code is that in the console I get the result : nonono
Thank you for your answers