Skip to content

Commit

Permalink
fix(form-field): annotate base class with Directive for Ivy (#17457)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and mmalerba committed Oct 21, 2019
1 parent 67b009f commit 4663d8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/material/form-field/form-field-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@

import {Observable} from 'rxjs';
import {NgControl} from '@angular/forms';
import {Directive} from '@angular/core';


/** An interface which allows a control to work inside of a `MatFormField`. */
@Directive({
// The @Directive with selector is required here because we're still running a lot of things
// against ViewEngine where directives without selectors are not allowed.
// TODO(crisbeto): convert to a selectorless Directive after we switch to Ivy.
selector: 'do-not-use-abstract-mat-form-field-control',
})
export abstract class MatFormFieldControl<T> {
/** The value of the control. */
value: T | null;
Expand Down
5 changes: 5 additions & 0 deletions src/material/form-field/form-field-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {MatLabel} from './label';
import {MatPlaceholder} from './placeholder';
import {MatPrefix} from './prefix';
import {MatSuffix} from './suffix';
import {MatFormFieldControl} from './form-field-control';


@NgModule({
Expand All @@ -27,6 +28,10 @@ import {MatSuffix} from './suffix';
MatPlaceholder,
MatPrefix,
MatSuffix,

// TODO(crisbeto): can be removed once `MatFormFieldControl`
// is turned into a selector-less directive.
MatFormFieldControl as any,
],
imports: [
CommonModule,
Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export * from './form-field-module';
export * from './error';
export * from './form-field';
export * from './form-field-control';
export {MatFormFieldControl} from './form-field-control';
export * from './form-field-errors';
export * from './hint';
export * from './placeholder';
Expand Down

0 comments on commit 4663d8f

Please sign in to comment.