1
Watch the image;
This image appears when the textbox is different from NULL as shown below;
But it should only appear when editing.
This is my component class responsible for this page;
export class BaseFormComponent implements OnInit {
form: FormGroup;
isInsertMode: boolean = true;
private NEW = 'new';
constructor(private _formBuilder: FormBuilder,
public baseService: BaseService,
private activatedRoute: ActivatedRoute, ) {
}
ngOnInit() {
this.form = BaseForm.createForm(this._formBuilder);
const { id } = this.activatedRoute.snapshot.params;
this.isInsertMode = id === this.NEW;
if (this.isInsertMode) {
this.montaReferencia();
}
}
private montaReferencia() {
this.form.get('descricao').valueChanges.subscribe(descricao => {
this.form.get('referencia').setValue(StringUtils.removeAccent(this.retiraEspacos(descricao)).toUpperCase());
});
}
private retiraEspacos(value: string) {
return value.replace(/[-\s]/g, '_');
}
}
Please, what I need is to create a method that is placed within that condition below, that by being true it automatically calls that message;
if (this.isInsertMode) {
this.montaReferencia();
}