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


TypeScript FormBuilder.array方法代码示例

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


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

示例1: it

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

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

示例2: 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

示例3: ngOnInit

  ngOnInit() {
    this.myFormGroup = this.fb.group({
      myElements: this.fb.array([])
    });

    this.addElementToArray();
  }
开发者ID:kakaby,项目名称:WhiteRabbit,代码行数:7,代码来源:reactive-form-multiply-input.component.ts

示例4: createForm

createForm() {
  this.privacyForm = this.fb.group({
    policyHeading: [''],
    policies: this.fb.array([]),
  });
  this.addForm();
}
开发者ID:RIntegerB2B,项目名称:SaifSeller,代码行数:7,代码来源:privacy-policy.component.ts

示例5: ngOnInit

ngOnInit() {
  this.registrationForm = this.fb.group({
    userName: ['', [Validators.required, Validators.minLength(3), forbiddenNameValidator(/password/)] ],
    password: [''],
    email: [''],
    subscribe: [''],
    confirmPassword: [''],
    address: this.fb.group({
      city: [''],
      state: [''],
      postalCode: ['']
    }),
    alternateEmails: this.fb.array([])
  }, {validator: PasswordValidator});

  this.registrationForm.get('subscribe').valueChanges
    .subscribe(checkedValue => {
      const email = this.registrationForm.get('email');
      if (checkedValue) {
        email.setValidators(Validators.required);
      } else {
        email.clearValidators();
      }
      email.updateValueAndValidity();
    });

}
开发者ID:jon-campbell1,项目名称:Angular-Reactive-Forms,代码行数:27,代码来源:app.component.ts

示例6: createForm

createForm() {
  this.faqForm = this.fb.group({
    faqHeading: [''],
    faqs: this.fb.array([]),
  });
  this.addForm();
}
开发者ID:RIntegerB2B,项目名称:SaifSeller,代码行数:7,代码来源:faq.component.ts

示例7: setObjectives

 setObjectives() {
   /* const objectives = this.board.selectObjectives
     .map(o => { return { organizationId: o.organization.id, objective: o.objective }}); */
   const objectiveFGs = this.board.selectObjectives.map(o => this.fb.group(o));
   const objectiveFormArray = this.fb.array(objectiveFGs);
   this.form.setControl('selectObjectives', objectiveFormArray);
 }
开发者ID:wolfhoundjesse,项目名称:AMI,代码行数:7,代码来源:edit-board.component.ts

示例8: ngOnInit

        ngOnInit() {
            this.formArray =
                this.builder.array([]);

            this.formGroup = this.builder.group({
                positionen: this.formArray
            });
        }
开发者ID:haschi,项目名称:dominium,代码行数:8,代码来源:gruppe.component.spec.ts

示例9: initClubTimeLine

 // TimeLine
 initClubTimeLine(): FormArray {
   const formArray = [];
   if (this.club.timeLine) {
     for (let i = 0; i < this.club.timeLine.length; i++) {
       formArray.push(this.initTimeLineEvent(this.club.timeLine[i]));
     }
   }
   return this.fb.array(formArray);
 }
开发者ID:Meistercoach83,项目名称:sfw,代码行数:10,代码来源:club-detail-history.component.ts

示例10: constructor

	// I initialize the reactive-form component.
	constructor( formBuilder: FormBuilder ) {

		this.formBuilder = formBuilder;

		this.form = this.formBuilder.group({
			pets: this.formBuilder.array( [] )
		});

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:10,代码来源:reactive-form.component.ts

示例11: savePv

  savePv(pv: PersistentVolume) {
    if (pv && pv.spec) {
      this.pv = pv;
      let storage;
      if (pv.spec.capacity) {
        storage = parseFloat(pv.spec.capacity['storage']);
      }
      let readWriteOnce = false;
      let readOnlyMany = false;
      let readWriteMany = false;
      if (pv.spec.accessModes && pv.spec.accessModes.length > 0) {
        pv.spec.accessModes.map(key => {
          switch (key) {
            case 'ReadWriteOnce':
              readWriteOnce = true;
              break;
            case 'ReadOnlyMany':
              readOnlyMany = true;
              break;
            case 'ReadWriteMany':
              readWriteMany = true;
              break;
          }
        });
      }
      let labels = Array<FormGroup>();
      if (pv.metadata.labels) {
        Object.getOwnPropertyNames(pv.metadata.labels).map(key => {
          labels.push(this.fb.group({
            key: key,
            value: pv.metadata.labels[key]
          }))
        });
      }
      let type = '0';
      if (pv.spec.cephfs) {
        type = 'cephfs';
      } else if (pv.spec.rbd) {
        type = 'rbd';
      }

      this.currentForm = this.fb.group({
        name: pv.metadata.name,
        type: type,
        storage: storage,
        rbdImage: pv.spec.rbd ? pv.spec.rbd.image : '',
        cephfsPath: pv.spec.cephfs ? pv.spec.cephfs.path : '',
        accessModes: this.fb.group({
          ReadWriteOnce: readWriteOnce,
          ReadOnlyMany: readOnlyMany,
          ReadWriteMany: readWriteMany,
        }),
        labels: this.fb.array(labels)
      });
    }
  }
开发者ID:jacky68147527,项目名称:wayne,代码行数:56,代码来源:create-edit-persistentvolume.component.ts

示例12: createForm

  createForm() {
    this.form = this.fb.group({
      'active': null,
      'title': null,
      'rankId': null,
      'conveneOn': null,
      'selectObjectives': this.fb.array([])
    });

  }
开发者ID:wolfhoundjesse,项目名称:AMI,代码行数:10,代码来源:edit-board.component.ts

示例13: it

        it('should set updateOn with nested arrays', () => {
          const g = b.group(
              {
                arr: b.array([b.control(''), b.control('')]),
              },
              {updateOn: 'blur'});

          expect(g.get(['arr', 0]) !.updateOn).toEqual('blur');
          expect(g.get(['arr', 1]) !.updateOn).toEqual('blur');
          expect(g.get('arr') !.updateOn).toEqual('blur');
        });
开发者ID:Cammisuli,项目名称:angular,代码行数:11,代码来源:form_builder_spec.ts

示例14: constructor

 constructor(builder: FormBuilder) {
   this.registrationForm = builder.group({
     username: null,
     email: null,
     password: null,
     address: builder.group({
       street: null,
       city: null,
       zip: null
     }),
     phones: builder.array([builder.control(null)])
   });
 }
开发者ID:niralmunjariya,项目名称:angular-dynamic-forms,代码行数:13,代码来源:form-builder.component.ts

示例15: ngOnInit

  ngOnInit() {

    this.myFormGroup = this.fb.group({
      angles: this.fb.array([])
    });
    this.addAngle();
    this.addAngle();
    this.addAngle();

    this.angleArray.valueChanges
      .pipe(debounceTime(1500))
      .subscribe(() => {
        this.recalculateTheAngles();
      });
  }
开发者ID:kakaby,项目名称:WhiteRabbit,代码行数:15,代码来源:sum-of-polygon-angles.component.ts


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