小编use*_*739的帖子

不推荐使用 Angular FormBuilder 组

我看到有一个主题看起来像我的,但它并没有真正回答我的问题,因为我们没有以相同的方式管理错误。不推荐使用 FormBuilder 组

首先,我刚刚迁移到 Angular 11,现在遇到了这个问题:

group is deprecated: This api is not typesafe and can result in issues with Closure Compiler renaming.
Use the `FormBuilder#group` overload with `AbstractControlOptions` instead.
Run Code Online (Sandbox Code Playgroud)

在此页面中,我会在页面上自动生成许多表单,在日期范围的情况下,我使用两个日期选择器。我创建了一个函数来检查 2 个日期选择器中的值。

成分:

newGroup = this.fb.group(
        {
          [node.type + '_' + node.objectId + '_dateFrom']: [
            '',
            [Validators.required]
          ],
          [node.type + '_' + node.objectId + '_dateTo']: [
            '',
            [Validators.required]
          ]
        },
        {
          validator: CheckFromToDate(
            node.type + '_' + node.objectId + '_dateFrom',
            node.type + '_' + node.objectId + '_dateTo'
          ) …
Run Code Online (Sandbox Code Playgroud)

angular2-forms angular2-formbuilder angular-validation angular angular2-form-validation

2
推荐指数
1
解决办法
1986
查看次数