mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-18 14:22:35 +00:00
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { FuseLayoutService } from '../../../../core/services/layout.service';
|
|
|
|
@Component({
|
|
selector : 'fuse-coming-soon',
|
|
templateUrl: './coming-soon.component.html',
|
|
styleUrls : ['./coming-soon.component.scss']
|
|
})
|
|
export class FuseComingSoonComponent implements OnInit
|
|
{
|
|
comingSoonForm: FormGroup;
|
|
comingSoonFormErrors: any;
|
|
|
|
constructor(private layoutService: FuseLayoutService, private formBuilder: FormBuilder)
|
|
{
|
|
this.layoutService.setSettings({
|
|
navigation: 'none',
|
|
toolbar : 'none',
|
|
footer : 'none'
|
|
});
|
|
|
|
this.comingSoonFormErrors = {
|
|
email: {}
|
|
};
|
|
}
|
|
|
|
ngOnInit()
|
|
{
|
|
this.comingSoonForm = this.formBuilder.group({
|
|
email: ['', [Validators.required, Validators.email]]
|
|
});
|
|
|
|
this.comingSoonForm.valueChanges.subscribe(() => {
|
|
this.onRegisterFormValuesChanged();
|
|
});
|
|
}
|
|
|
|
onRegisterFormValuesChanged()
|
|
{
|
|
for ( const field in this.comingSoonFormErrors )
|
|
{
|
|
if ( !this.comingSoonFormErrors.hasOwnProperty(field) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Clear previous errors
|
|
this.comingSoonFormErrors[field] = {};
|
|
|
|
// Get the control
|
|
const control = this.comingSoonForm.get(field);
|
|
|
|
if ( control && control.dirty && !control.valid )
|
|
{
|
|
this.comingSoonFormErrors[field] = control.errors;
|
|
}
|
|
}
|
|
}
|
|
}
|