Этот код работает нормально
async save(input: HTMLInputElement) {
const file = input.files.item(0);
if (this.form.valid) {
const data = this.form.getRawValue();
await this.fireDatabase.object(`/Devices/${data.name}`).set(data);
this.snackBar.open('Device successfully created', 'close', {
duration: 2000
});
this.form.reset();
input.value = '';
}
}
Но если я проверяю с if
условие
async save(input: HTMLInputElement) {
const file = input.files.item(0);
if (this.form.valid) {
if (true) {
this.snackBar.open('error', 'close', {
duration: 2000
});
}
const data = this.form.getRawValue();
await this.fireDatabase.object(`/Devices/${data.name}`).set(data);
this.snackBar.open('Device successfully created', 'close', {
duration: 2000
});
this.form.reset();
input.value = '';
}
}
, тогда он не возвращает функцию.
Какэто исправить?
Я использую Angular и Angularfire