当前位置: 首页>>代码示例>>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;未经允许,请勿转载。