@ rxweb / reactive-form-validators基于装饰器的验证消失了形式的转换器

时间:2019-08-01 08:15:12

标签: angular angular-reactive-forms angular-translate

#context   我已经在模型名称中添加了formControlName,它工作正常。添加翻译后,它停止工作并表现出怪异,我没有明白是什么原因导致了#translation.i取消注释,如果我在html翻译中取消了一些子分类div会回来的。

角度翻译器#反应形式#基于模型的

//组件

    import { RxFormBuilder } from '@rxweb/reactive-form-validators';
    import { ReactiveFormConfig } from '@rxweb/reactive-form-validators';


    @Component({
      selector: 'app-sob-create-update-action-plan',
      templateUrl: './create-update-action-plan.component.html',
      styleUrls: ['./create-update-action-plan.component.scss']
    })
    export class CreateUpdateActionPlanComponent implements OnInit {

      actionPlanFormGroup: FormGroup;
      actionPlanDetails: ActionPlanModel;

      constructor(
        private formBuilder: RxFormBuilder
    ) { }

      ngOnInit() {
        ReactiveFormConfig.set({
          validationMessage: {
              required: 'This field is required',
          }
      });
        this.actionPlanDetails =  new ActionPlanModel();
        this.actionPlanFormGroup = this.formBuilder.formGroup(this.actionPlanDetails);
      }

    }

    Model class 

    import { required, compare, maxLength } from '@rxweb/reactive-form-validators';

    export class ActionPlanModel {

       private year: number;
       private scheme: number;
       private subScheme: number;
       private grantingAllocationOrderNo: number;
       private district: string;
       private ULBName: string;
       private schemeGrant: string;
       private grantOrderNo: string;
       private grantOrderDate: string;
       private grantOrderAmount: string;
       private actionPlanApprovalNo: string;
       private actionPlanApprovalDate: string;
       private grantAmountForSelectedSubScheme: string;
       private approvalAmount: string;


        public getYear(): number {
            return this.year;
        }

        @maxLength({value: 50 })
        @required()
        public setYear(year: number): void {
            this.year = year;
        }

        public getScheme(): number {
            return this.scheme;
        }

        @maxLength({value: 50 })
        @required()
        public setScheme(scheme: number): void {
            this.scheme = scheme;
        }

       //I have setters and getters for all the fields like above
     constructor(){}

    }

0 个答案:

没有答案