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


TypeScript model.FormArray类代码示例

本文整理汇总了TypeScript中@angular/forms/src/model.FormArray的典型用法代码示例。如果您正苦于以下问题:TypeScript FormArray类的具体用法?TypeScript FormArray怎么用?TypeScript FormArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: it

      it('should not make a dirty array not dirty when disabling controls', () => {
        const c = new FormControl('one');
        const c2 = new FormControl('two');
        const a = new FormArray([c, c2]);

        a.markAsDirty();
        expect(a.dirty).toBe(true);
        expect(c.dirty).toBe(false);

        c.disable();
        expect(a.dirty).toBe(true);

        c.enable();
        expect(a.dirty).toBe(true);
      });
开发者ID:Cammisuli,项目名称:angular,代码行数:15,代码来源:form_control_spec.ts

示例2: it

        it('should default to array updateOn when not set in control', () => {
          const a = new FormArray([new FormControl(), new FormControl()], {updateOn: 'blur'});

          expect(a.get([0]) !.updateOn).toEqual('blur');
          expect(a.get([1]) !.updateOn).toEqual('blur');
        });
开发者ID:DeepanParikh,项目名称:angular,代码行数:6,代码来源:form_control_spec.ts

示例3: addFormArray

 addFormArray(): void {
   this.cor_dataset_actor_array.push(this._formService.generateCorDatasetActorForm());
 }
开发者ID:PnEcrins,项目名称:GeoNature,代码行数:3,代码来源:dataset-form.component.ts

示例4: postDataset

  postDataset() {
    const cor_dataset_actor_array = JSON.parse(JSON.stringify(this.cor_dataset_actor_array.value));
    const update_cor_dataset_actor = [];
    this._formService.formValid = true;

    cor_dataset_actor_array.forEach(element => {
      update_cor_dataset_actor.push(element);
      this._formService.checkFormValidity(element);
    });

    if (this._formService.formValid) {
      const dataset = Object.assign(this.datasetForm.value, {});

      dataset['cor_dataset_actor'] = update_cor_dataset_actor;
      this._api.post<any>(`${AppConfig.API_ENDPOINT}/meta/dataset`, dataset).subscribe(
        data => {
          this._router.navigate(['/metadata/datasets']);
          this._commonService.translateToaster('success', 'MetaData.Datasetadded');
        },
        error => {
          if (error.status === 403) {
            this._commonService.translateToaster('error', 'NotAllowed');
          } else {
            this._commonService.translateToaster('error', 'ErrorMessage');
          }
        }
      );
    }
  }
开发者ID:PnEcrins,项目名称:GeoNature,代码行数:29,代码来源:dataset-form.component.ts

示例5: setTimeout

 data.cor_dataset_actor.forEach((cor, index) => {
   if (index === 0) {
     this.cor_dataset_actor_array.controls[index].patchValue(cor);
   } else {
     const formCor = this._formService.generateCorDatasetActorForm();
     this.cor_dataset_actor_array.push(formCor);
     //hack pour attendre que le template soit rendu avant de mettre les valeurs au formulaire
     setTimeout(() => {
       this.cor_dataset_actor_array.controls[index].patchValue(cor);
     }, 2000);
   }
 });
开发者ID:PnEcrins,项目名称:GeoNature,代码行数:12,代码来源:dataset-form.component.ts

示例6: ngOnInit

  ngOnInit() {
    // get the id from the route
    this._route.params.subscribe(params => {
      this.id_dataset = params['id'];
      if (this.id_dataset) {
        this.getDataset(this.id_dataset);
      }
    });
    this.datasetForm = this._fb.group({
      id_acquisition_framework: [null, Validators.required],
      id_dataset: null,
      dataset_name: [null, Validators.compose([Validators.required, Validators.maxLength(150)])],
      dataset_shortname: [
        null,
        Validators.compose([Validators.required, Validators.maxLength(30)])
      ],
      dataset_desc: [null, Validators.required],
      id_nomenclature_data_type: [null, Validators.required],
      keywords: null,
      marine_domain: true,
      terrestrial_domain: false,
      id_nomenclature_dataset_objectif: [null, Validators.required],
      //TODO bouding-box
      id_nomenclature_collecting_method: [null, Validators.required],
      id_nomenclature_data_origin: [null, Validators.required],
      id_nomenclature_source_status: [null, Validators.required],
      id_nomenclature_resource_type: [null, Validators.required],
      default_validity: true,
      active: [true, Validators.required]
    });

    this.cor_dataset_actor_array = this._fb.array([]);

    this._dfs.getAcquisitionFrameworks().subscribe(data => {
      this.acquisitionFrameworks = data;
    });

    this.cor_dataset_actor_array.push(this._formService.generateCorDatasetActorForm());
  }
开发者ID:PnEcrins,项目名称:GeoNature,代码行数:39,代码来源:dataset-form.component.ts


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