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


TypeScript common.FormBuilder類代碼示例

本文整理匯總了TypeScript中angular2/common.FormBuilder的典型用法代碼示例。如果您正苦於以下問題:TypeScript FormBuilder類的具體用法?TypeScript FormBuilder怎麽用?TypeScript FormBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: constructor

 constructor(fb: FormBuilder) {
   this.form = fb.group({
    oldPassword: ['', Validators.required],
    newPassword: ['', Validators.compose([Validators.required, PasswordValidators.passwordComplexity])], 
    confirmPassword: ['', Validators.required] 
   }, { validator: PasswordValidators.unmatchingPasswords });
 }
開發者ID:fox-eye,項目名稱:angular2-udemy-mosh,代碼行數:7,代碼來源:change-password-form.component.ts

示例2: constructor

 constructor(fb: FormBuilder) { 
     this.myFrom = fb.group({
         name: "Arsalan",
         age: 24,
         email: "a4arshi@yahoo.com"
     })
 }
開發者ID:MOHAMMADArsalan,項目名稱:NG2BOOK,代碼行數:7,代碼來源:app.component.ts

示例3: constructor

    /**
     * The Add-Folder modal
     * @param {NavParams} contains data passed from the caller (under
     * navParams.data.parentItems).
     * @param {viewController} used to dismiss this modal with data to
     * return to the caller.
     * @param {FormBuilder} used to build the form of this modal.
     */
    constructor(
        private navParams: NavParams,
        private viewController: ViewController,
        private formBuilder: FormBuilder
    ) {
        // passed in a string with the parent path in it
        this.parentPath = navParams.data.parentPath;

        let hasSlash = (control: Control): ValidationResult => {
            console.log('HS validator control.value: ' + control.value);
            if (control.value !== '' && control.value.indexOf('/') !== -1) {
                return { hasSlash: true };
            }
            return null;
        };

        let alreadyExists = (control: Control): ValidationResult => {
            if (control.value === '') {
                // alert('did not expect control.value to be empty');
                return null;
            }

            if (!(this.navParams &&
                this.navParams.data &&
                this.navParams.data.parentItems &&
                Object.keys(this.navParams.data.parentItems).length)) {
                // nav params have not been sent yet or they are empty
                return null;
            }
            // for non empty control.value (which carries the string
            // that was added on the input line), check that it isn't
            // already in this.navParams.data.parentItems, but we have
            // to search it by name
            let newName: string = control.value,
                parentItems: { [id: string]: TreeNode } =
                    this.navParams.data.parentItems,
                parentKeys: string[] = Object.keys(parentItems),
                key: number;
            for (key = 0; key < parentKeys.length; key++) {
                let parentKey: string = parentKeys[key];
                if (newName === parentItems[parentKey].name) {
                    return { alreadyExists: true };
                }
            }
            return null;
        };

        this.nameControl = new Control(
            '',
            Validators.compose([
                Validators.required,
                alreadyExists,
                hasSlash
            ]));

        this.form = formBuilder.group({
            nameControl: this.nameControl
        });
    }
開發者ID:factorypreset,項目名稱:ionic-recorder,代碼行數:67,代碼來源:add-folder.ts

示例4: constructor

 constructor(private _dialogService: DialogService,
     private _empTimeSheetService: EmployeeTimeSheetService,
     private _fb: FormBuilder) {
     this._form = _fb.group({
         
     });
     this._date = new Date();
 }
開發者ID:lnaie,項目名稱:Tailor,代碼行數:8,代碼來源:employees-time-sheets.component.ts

示例5: constructor

 constructor(viewCtrl: ViewController, form: FormBuilder) {
   this.viewCtrl = viewCtrl;
   this.projectForm = form.group({
     name: ['', Validators.required],
     description: ['', Validators.required],
     tags: ['', Validators.required]
   });
 }
開發者ID:CompassSoftware,項目名稱:xpsp,代碼行數:8,代碼來源:create-project.mod.ts

示例6: constructor

 constructor(fb: FormBuilder) {
     this.form = fb.group({
         username: ['', Validators.compose([Validators.required, 
         UsernameValidators.cannotContainSpace]),
         UsernameValidators.shouldBeUnique],
         password: ['', Validators.required]
     })
 }
開發者ID:zinyando,項目名稱:learning-ng,代碼行數:8,代碼來源:login-form.ts

示例7: constructor

 constructor(public http: Http, fb: FormBuilder){
     this.myForm = fb.group({
         'sku': ['ABC123', Validators.required],
         'sku1': ['ABC123', Validators.required]
     });
     
     this.sku = this.myForm.controls['sku'];
 } 
開發者ID:HansS,項目名稱:Teaching-Ionic-MeanStack-SSUET-2015-May-ModuleB,代碼行數:8,代碼來源:app.ts

示例8: buildForm

  buildForm(): void {
    this.newTodo = new Control('', Validators.required);

    this.myForm = this.fb.group({
      'newTodo': this.newTodo
    });
  }
開發者ID:jollivetc,項目名稱:ng2_play,代碼行數:7,代碼來源:todo.ts

示例9: toControlGroup

  toControlGroup(questions:QuestionBase<any>[] ) {
    let group = {};

    questions.forEach(question => {
      group[question.key] = question.required ? [question.value || '', Validators.required] : [];
    });
    return this._fb.group(group);
  }
開發者ID:BaronVonPerko,項目名稱:angular.io,代碼行數:8,代碼來源:question-control.service.ts

示例10: ngOnInit

 ngOnInit() {
     this.form = this._fb.group({
         "firstName": ["", Validators.compose([Validators.required])],
         "lastName":  ["", Validators.compose([Validators.required])],
         "email":     ["", Validators.compose([Validators.required, FormValidator.emailValidator])],
         "password":  ["", Validators.compose([Validators.required, FormValidator.passwordValidator])]
     });
 }
開發者ID:,項目名稱:,代碼行數:8,代碼來源:


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