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


TypeScript CustomValidators.equalTo方法代碼示例

本文整理匯總了TypeScript中ng2-validation.CustomValidators.equalTo方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CustomValidators.equalTo方法的具體用法?TypeScript CustomValidators.equalTo怎麽用?TypeScript CustomValidators.equalTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ng2-validation.CustomValidators的用法示例。


在下文中一共展示了CustomValidators.equalTo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

    constructor(
        formBuilder: FormBuilder,
        private router: Router,
        private authService: AuthService,
        private jwtService: JwtService,
        private userService: UserService
    ) {
        super();

        const password = new FormControl('', [
            Validators.required,
            Validators.minLength(6)
        ]);

        this.form = formBuilder.group({
            username: ['', [
                Validators.required,
                Validators.minLength(2)
            ]],
            plainPassword: formBuilder.group({
                first: password,
                second: ['', [
                    Validators.required,
                    CustomValidators.equalTo(password)
                ]]
            })
        });
    }
開發者ID:Invis1ble,項目名稱:assistant-client,代碼行數:28,代碼來源:registration.component.ts

示例2: constructor

    constructor(public settings: SettingsService, fb: FormBuilder) {

        let password = new FormControl('', Validators.compose([Validators.required, Validators.pattern('^[a-zA-Z0-9]{6,10}$')]));
        let certainPassword = new FormControl('', [Validators.required, CustomValidators.equalTo(password)]);

        this.passwordForm = fb.group({
            'password': password,
            'confirmPassword': certainPassword
        });

        this.valForm = fb.group({
            'email': [null, Validators.compose([Validators.required, CustomValidators.email])],
            'accountagreed': [null, Validators.required],
            'passwordGroup': this.passwordForm
        });
    }
開發者ID:echolaw,項目名稱:work-day,代碼行數:16,代碼來源:register.component.ts

示例3: FormControl

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';

const password = new FormControl('', Validators.required);
const confirmPassword = new FormControl('', CustomValidators.equalTo(password));

@Component({
  selector: 'app-signup',
  templateUrl: './signup.component.html',
  styleUrls: ['./signup.component.scss']
})
export class SignupComponent implements OnInit {

  public form: FormGroup;
  constructor(private fb: FormBuilder, private router: Router) { }

  ngOnInit() {
    this.form = this.fb.group({
      uname: [null, Validators.compose([Validators.required])],
      password: password,
      confirmPassword: confirmPassword
    });
  }

  onSubmit() {

    this.router.navigate(['/']);
  }
開發者ID:bhavdip13,項目名稱:Angular5_core2.1_EfCore,代碼行數:30,代碼來源:signup.component.ts


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