当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript FormBuilder.control方法代码示例

本文整理汇总了TypeScript中@angular/forms.FormBuilder.control方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormBuilder.control方法的具体用法?TypeScript FormBuilder.control怎么用?TypeScript FormBuilder.control使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/forms.FormBuilder的用法示例。


在下文中一共展示了FormBuilder.control方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ngOnInit

  ngOnInit() {

    this.usuario = new UsuarioModel();
    this.usuario.nome = 'b';
    this.usuario.username = '';
    this.usuario.email = '';

    this.usuarioForm = this.formBuilder.group({
      nome: this.formBuilder.control(this.usuario.nome),
      email: this.formBuilder.control(this.usuario.email),
      username: this.formBuilder.control(this.usuario.username),
      // password: this.formBuilder.control('', [
      //   Validators.required,
      //   Validators.minLength(1)
      // ]),
      // consfirm: this.formBuilder.control('', [
      //   Validators.required,
      //   Validators.minLength(1)
      // ]),
    });


    let idUsuario: string = '';
    if (
      this.activatedRoute.snapshot.paramMap.get('id') != null &&
      this.activatedRoute.snapshot.paramMap.get('id') != undefined
    ) {
      idUsuario = this.activatedRoute.snapshot.paramMap.get('id');

      this.usuarioService.getUsuario(idUsuario).subscribe(data => {
        this.usuario = data.data;
      });
    }
  }
开发者ID:jordangrego,项目名称:dotNetCore,代码行数:34,代码来源:cadastro-usuario.component.ts

示例2: ngOnInit

 ngOnInit(): void {
   this.email = this.formBuilder.control('', Validators.email);
   this.password = this.formBuilder.control('', Validators.required);
   this.formGroup = this.formBuilder.group({
     email: ['', Validators.email],
     password: ['', Validators.required]
   });
 }
开发者ID:hatorach,项目名称:tcrs,代码行数:8,代码来源:login.component.ts

示例3: constructor

 constructor(private ts: TimeSpecService, fb: FormBuilder, private _router: Router, private _route: ActivatedRoute) {
   this.begin    = fb.control('', null);  // XXX date validators
   this.end      = fb.control('', null);  // XXX date validators
   this.duration = fb.control('', durationValidator);
   this.stepsize = fb.control('', durationValidator);
   this.formModel = fb.group({
     begin: this.begin,
     end: this.end,
     duration: this.duration,
     stepsize: this.stepsize,
   });
 }
开发者ID:groupon,项目名称:monsoon,代码行数:12,代码来源:time-spec-modal.component.ts

示例4: it

    it('should create control arrays', () => {
      const c = b.control('three');
      const e = b.control(null);
      const f = b.control(undefined);
      const a = b.array(
          ['one', ['two', syncValidator], c, b.array(['four']), e, f], syncValidator,
          asyncValidator);

      expect(a.value).toEqual(['one', 'two', 'three', ['four'], null, null]);
      expect(a.validator).toBe(syncValidator);
      expect(a.asyncValidator).toBe(asyncValidator);
    });
开发者ID:lucduong,项目名称:angular,代码行数:12,代码来源:form_builder_spec.ts

示例5: addControl

    /**
     * Add the form control for the search mode.
     *
     * @param {string} fieldName Control field name.
     * @param {any}    value     Initial set value.
     */
    protected addControl(fieldName: string, value?: any): void {
        if (!this.form) {
            return;
        }

        if (this.mode == 'search') {
            this.form.addControl(fieldName, this.fb.control(this.search[fieldName] || null));
        }

        if (this.mode == 'edit') {
            this.form.addControl(fieldName, this.fb.control(value, this.field.required ? Validators.required : null));
        }
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:19,代码来源:field-plugin-component.ts

示例6: ngOnInit

 ngOnInit() {
   this.email = this.formBuilder.control('', Validators.email);
   this.password = this.formBuilder.control('', Validators.compose(
     [Validators.minLength(8), CustomValidators.passwordComplexity]));
   this.passwordConfirmation = this.formBuilder.control('');
   this.form = this.formBuilder.group({
     email: this.email,
     password: this.password,
     passwordConfirmation: this.passwordConfirmation
   }, {
     validator: CustomValidators.confirmPassword()
   });
 }
开发者ID:hatorach,项目名称:tcrs,代码行数:13,代码来源:registration.component.ts

示例7: it

        it('should set updateOn with complex setup', () => {
          const g = b.group({
            group: b.group(
                {one: b.control('', {updateOn: 'change'}), two: b.control('')}, {updateOn: 'blur'}),
            groupTwo: b.group({one: b.control('')}, {updateOn: 'submit'}),
            three: b.control('')
          });

          expect(g.get('group.one') !.updateOn).toEqual('change');
          expect(g.get('group.two') !.updateOn).toEqual('blur');
          expect(g.get('groupTwo.one') !.updateOn).toEqual('submit');
          expect(g.get('three') !.updateOn).toEqual('change');
        });
开发者ID:Cammisuli,项目名称:angular,代码行数:13,代码来源:form_builder_spec.ts

示例8: updateForm

  function updateForm(name, description, birthdate) {
    if (!component.personForm) {
      component.personForm = formBuilder.group({
        Name: formBuilder.control({}),
        Description: formBuilder.control({}),
        BirthDate: formBuilder.control({}),
      });
    }

    component.personForm.controls['Name'].setValue(name);
    component.personForm.controls['Description'].setValue(description);
    component.personForm.controls['BirthDate'].setValue(birthdate);
  }
开发者ID:jsnmgpnty,项目名称:pngo-fe-test,代码行数:13,代码来源:personForm.component.spec.ts

示例9:

 this.clubs.map((club: Club) => {
   const clubControl: FormControl = this.fb.control(club);
   const nameControl: FormControl = this.fb.control(club.clubName, [
     Validators.required,
     Validators.minLength(3),
     Validators.maxLength(250),
     this.existingClubName()
   ]);
   const group: FormGroup = this.fb.group({
     name: nameControl,
     club: clubControl
   });
   newClubsArray.push(group);
 });
开发者ID:PloughingAByteField,项目名称:tiatus,代码行数:14,代码来源:clubs.component.ts

示例10: ngOnInit

 public ngOnInit() {
   this.translate.setDefaultLang('en');
   this.translate.use('en');
   this.loginForm = this.fb.group({
     name: this.fb.control('', [
       Validators.required,
       Validators.minLength(3),
       Validators.maxLength(250)
     ]),
     password: this.fb.control('', [
       Validators.required,
       Validators.minLength(8),
       Validators.maxLength(250)
     ])
   });
 }
开发者ID:PloughingAByteField,项目名称:tiatus,代码行数:16,代码来源:login.component.ts


注:本文中的@angular/forms.FormBuilder.control方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。