當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AbstractControl.get方法代碼示例

本文整理匯總了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;
}
開發者ID:connelb,項目名稱:fitwithlc,代碼行數:25,代碼來源:date-range.validator.ts

示例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 };
};
開發者ID:yurlovm,項目名稱:lab12,代碼行數:8,代碼來源:password-matcher.ts

示例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;
}
開發者ID:Dkumarsable,項目名稱:angular,代碼行數:8,代碼來源:password.validator.ts

示例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;
    }
開發者ID:krzysztofkarp,項目名稱:udemy-angular,代碼行數:9,代碼來源:password.validators.ts

示例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;
   }
 }
開發者ID:aqsach,項目名稱:new_cramefrenzy,代碼行數:9,代碼來源:password-validator.component.ts

示例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
     }
 }
開發者ID:kittycash,項目名稱:marketplace,代碼行數:9,代碼來源:password-validation.ts

示例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;
  }
開發者ID:reisub0,項目名稱:mainflux,代碼行數:9,代碼來源:signup.component.ts

示例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;
   }
 };
開發者ID:systers,項目名稱:PC-Prep-Kit,代碼行數:9,代碼來源:Validators.ts

示例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}};
 };
開發者ID:mwd-huyquangngo,項目名稱:SWATANG,代碼行數:9,代碼來源:field-validator.ts

示例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;
     }
 }
開發者ID:aqsach,項目名稱:new_cramefrenzy,代碼行數:9,代碼來源:password-validator.component.ts


注:本文中的@angular/forms.AbstractControl.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。