Skip to content

Commit 9e4bb31

Browse files
crisbetommalerba
authored andcommitted
fix(form-field): annotate base class with Directive for Ivy
This is a resubmit of #17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
1 parent c50aa21 commit 9e4bb31

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/material/form-field/form-field-control.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88

99
import {Observable} from 'rxjs';
1010
import {NgControl} from '@angular/forms';
11+
import {Directive} from '@angular/core';
1112

1213

1314
/** An interface which allows a control to work inside of a `MatFormField`. */
15+
@Directive({
16+
// The @Directive with selector is required here because we're still running a lot of things
17+
// against ViewEngine where directives without selectors are not allowed.
18+
// TODO(crisbeto): convert to a selectorless Directive after we switch to Ivy.
19+
selector: 'do-not-use-abstract-mat-form-field-control',
20+
})
1421
export abstract class MatFormFieldControl<T> {
1522
/** The value of the control. */
1623
value: T | null;

src/material/form-field/form-field-module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {MatLabel} from './label';
1616
import {MatPlaceholder} from './placeholder';
1717
import {MatPrefix} from './prefix';
1818
import {MatSuffix} from './suffix';
19+
import {MatFormFieldControl} from './form-field-control';
1920

2021

2122
@NgModule({
@@ -27,6 +28,10 @@ import {MatSuffix} from './suffix';
2728
MatPlaceholder,
2829
MatPrefix,
2930
MatSuffix,
31+
32+
// TODO(crisbeto): can be removed once `MatFormFieldControl`
33+
// is turned into a selector-less directive.
34+
MatFormFieldControl as any,
3035
],
3136
imports: [
3237
CommonModule,

src/material/form-field/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
export * from './form-field-module';
1010
export * from './error';
1111
export * from './form-field';
12-
export * from './form-field-control';
12+
export {MatFormFieldControl} from './form-field-control';
1313
export * from './form-field-errors';
1414
export * from './hint';
1515
export * from './placeholder';

0 commit comments

Comments
 (0)