Am new to angular2 and i have a class which has static functions in angular2 and i would like to implement a http request on one of the static functions that is
I have static classes that manage form validation
FORM VALIDTION
this.userform = this._formbuilder.group({
first_name: [this.user.first_name, Validators.required],
last_name: ['', Validators.required],
username: ['', Validators.compose(
[
Validators.required,Validators.minLength(5)
]
)],
password: ['',Validators.compose([
Validators.required,ValidationService.passwordValidator
])],
email: ['', Validators.compose([
Validators.required,ValidationService.emailValidator
])],
role: ['', Validators.required],
})
on the ValidationService
constructor(private _http:Http){}
static passwordValidator(control) {
if(control.value != undefined){
if (!control.value.match(/^(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{6,100}$/)) {
return { 'invalidPassword': true };
}
}
}
static emailValidator(){
return this._http. //this returns an error i would like to
//query server to see if email exists
}
In my case above how can i use the http in the static function probably by assigning it to a variable
That is let http...
This is being used Here but it was in RC5 whic fails to me