Skip to content

Commit a013fe2

Browse files
authored
feat(core): mark define fieldComponent optional for custom wrapper (#1694)
1 parent 8c77c65 commit a013fe2

File tree

15 files changed

+17
-33
lines changed

15 files changed

+17
-33
lines changed

demo/src/app/examples/bootstrap-specific/bootstrap-horizontal/horizontal-wrapper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -16,5 +16,4 @@ import { FieldWrapper } from '@ngx-formly/core';
1616
`,
1717
})
1818
export class FormlyHorizontalWrapper extends FieldWrapper {
19-
@ViewChild('fieldComponent', { read: ViewContainerRef }) fieldComponent: ViewContainerRef;
2019
}

demo/src/app/examples/other/hide-fields-with-animations/animation-wrapper.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
import { trigger, state, style, transition, animate, group } from '@angular/animations';
@@ -48,5 +48,4 @@ const SlideInOutAnimation = [
4848
animations: [SlideInOutAnimation],
4949
})
5050
export class AnimationWrapperComponent extends FieldWrapper {
51-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent: ViewContainerRef;
5251
}

demo/src/app/examples/other/material-prefix-suffix/addons.wrapper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, TemplateRef, ViewChild, ViewContainerRef, AfterViewInit } from '@angular/core';
1+
import { Component, TemplateRef, ViewChild, AfterViewInit } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -30,7 +30,6 @@ import { FieldWrapper } from '@ngx-formly/core';
3030
`,
3131
})
3232
export class FormlyWrapperAddons extends FieldWrapper implements AfterViewInit {
33-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent!: ViewContainerRef;
3433
@ViewChild('matPrefix') matPrefix: TemplateRef<any>;
3534
@ViewChild('matSuffix') matSuffix: TemplateRef<any>;
3635

demo/src/app/examples/other/nested-formly-forms/panel-wrapper.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -13,5 +13,4 @@ import { FieldWrapper } from '@ngx-formly/core';
1313
`,
1414
})
1515
export class PanelWrapperComponent extends FieldWrapper {
16-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent: ViewContainerRef;
17-
}
16+
}

demo/src/app/guides/custom-formly-wrapper.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ See live demo: [demo](https://stackblitz.com/angular/dleylnmrbmd?file=app%2Fapp.
5353
`,
5454
})
5555
export class PanelWrapperComponent extends FieldWrapper {
56-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent: ViewContainerRef;
5756
}
5857
```
5958

src/bootstrap/addons/src/addons.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -7,8 +7,6 @@ import { FieldWrapper } from '@ngx-formly/core';
77
styleUrls: ['./addons.component.scss'],
88
})
99
export class FormlyWrapperAddons extends FieldWrapper {
10-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent!: ViewContainerRef;
11-
1210
addonRightClick($event: any) {
1311
if (this.to.addonRight.onClick) {
1412
this.to.addonRight.onClick(this.to, this, $event);

src/bootstrap/src/lib/wrappers/form-field.wrapper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -21,5 +21,4 @@ import { FieldWrapper } from '@ngx-formly/core';
2121
`,
2222
})
2323
export class FormlyWrapperFormField extends FieldWrapper {
24-
@ViewChild('fieldComponent', { read: ViewContainerRef }) fieldComponent!: ViewContainerRef;
2524
}

src/core/src/lib/components/formly.field.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TestBed, ComponentFixture } from '@angular/core/testing';
22
import { createGenericTestComponent } from '../test-utils';
33

4-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
4+
import { Component } from '@angular/core';
55
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms';
66
import {
77
FormlyModule,
@@ -248,7 +248,6 @@ export class FormlyFieldText extends FieldType {}
248248
`,
249249
})
250250
export class FormlyWrapperLabel extends FieldWrapper {
251-
@ViewChild('fieldComponent', {read: ViewContainerRef}) fieldComponent: ViewContainerRef;
252251
}
253252

254253
export class Manipulator {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ViewContainerRef } from '@angular/core';
1+
import { ViewContainerRef, ViewChild } from '@angular/core';
22
import { FieldType } from './field.type';
33
import { FormlyFieldConfig } from '../components/formly.field.config';
44

55
export abstract class FieldWrapper<F extends FormlyFieldConfig = FormlyFieldConfig> extends FieldType<F> {
6-
fieldComponent: ViewContainerRef;
6+
@ViewChild('fieldComponent', { read: ViewContainerRef }) fieldComponent: ViewContainerRef;
77
}

src/ionic/src/lib/wrappers/form-field.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { FieldWrapper } from '@ngx-formly/core';
33

44
@Component({
@@ -22,6 +22,4 @@ import { FieldWrapper } from '@ngx-formly/core';
2222
</ion-item>
2323
`,
2424
})
25-
export class FormlyWrapperFormField extends FieldWrapper {
26-
@ViewChild('fieldComponent', { read: ViewContainerRef }) fieldComponent: ViewContainerRef;
27-
}
25+
export class FormlyWrapperFormField extends FieldWrapper {}

0 commit comments

Comments
 (0)