本文整理匯總了TypeScript中@angular/forms.AbstractControl.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AbstractControl.get方法的具體用法?TypeScript AbstractControl.get怎麽用?TypeScript AbstractControl.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/forms.AbstractControl
的用法示例。
在下文中一共展示了AbstractControl.get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: dateRangeValidator
export function dateRangeValidator(c: AbstractControl): {[key: string]: any} {
// Get controls in group
const startDateC = c.get('startDate');
const startTimeC = c.get('startTime');
const endDateC = c.get('endDate');
const endTimeC = c.get('endTime');
// Object to return if date is invalid
const invalidObj = { 'dateRange': true };
// If start and end dates are valid, can check range (with prefilled times)
// Final check happens when all dates/times are valid
if (startDateC.valid && endDateC.valid) {
const checkStartTime = startTimeC.invalid ? '12:00 AM' : startTimeC.value;
const checkEndTime = endTimeC.invalid ? '11:59 PM' : endTimeC.value;
const startDatetime = stringsToDate(startDateC.value, checkStartTime);
const endDatetime = stringsToDate(endDateC.value, checkEndTime);
if (endDatetime >= startDatetime) {
return null;
} else {
return invalidObj;
}
}
return null;
}
示例2:
export const passwordMatcher = (control: AbstractControl): {[key: string]: boolean} => {
const password = control.get('password');
const confirm = control.get('confirm');
if (!password || !confirm) {
return null;
}
return password.value === confirm.value ? null : { nomatch: true };
};
示例3: PasswordValidator
export function PasswordValidator(control: AbstractControl): { [key: string]: boolean } | null {
const password = control.get('password');
const confirmPassword = control.get('confirmPassword');
if (password.pristine || confirmPassword.pristine) {
return null;
}
return password && confirmPassword && password.value !== confirmPassword.value ? { 'misMatch': true } : null;
}
示例4: passwordsShouldMatch
static passwordsShouldMatch(control: AbstractControl) {
let newPassword = control.get('newPassword');
let confirmPassword = control.get('confirmPassword');
if (newPassword.value !== confirmPassword.value)
return { passwordsShouldMatch: true };
return null;
}
示例5: MatchPassword
static MatchPassword(AC: AbstractControl) {
const newPassword = AC.get('newPassword').value; // to get value in input tag
const newPassword2 = AC.get('newPassword2').value; // to get value in input tag
if (newPassword !== newPassword2) {
AC.get('newPassword2').setErrors( {MatchPassword: true} );
} else {
return null;
}
}
示例6: MatchPassword
static MatchPassword(AC: AbstractControl): any {
let password = AC.get('password').value; // Get the password input value
let passwordConfirm = AC.get('passwordConfirm').value; // get the passwordConfirm input value
if(password != passwordConfirm) {
AC.get('passwordConfirm').setErrors( {MatchPassword: true} )
} else {
return null
}
}
示例7: comparePasswords
comparePasswords(c: AbstractControl): { [key: string]: boolean } {
const pass = c.get('password');
const repeatPassword = c.get('repeatPassword');
if (pass.value !== repeatPassword.value) {
return { 'match': true };
}
return null;
}
示例8: ConfirmPasswordValidator
static ConfirmPasswordValidator(control: AbstractControl) {
const value = control.get('password').value;
const otherValue = control.get('confirmpassword').value;
if (value !== otherValue) {
control.get('confirmpassword').setErrors({MatchError: true});
} else {
return null;
}
};
示例9: return
return (control: AbstractControl): {[key: string]: any} | null => {
const password = control.get('newpassword').value;
const confirmPassword = control.get('confirmpassword').value;
const isValid = password === confirmPassword;
if (!isValid) {
control.get('confirmpassword').setErrors({matchPassword: true});
}
return isValid ? null : {'matchPassword': {value: confirmPassword}};
};
示例10: MatchPassword
static MatchPassword(AC: AbstractControl) {
const password = AC.get('password').value; // to get value in input tag
const confirmPassword = AC.get('confirmPassword').value; // to get value in input tag
if (password !== confirmPassword) {
AC.get('confirmPassword').setErrors({ MatchPassword: true });
} else {
return null;
}
}