I'd like to implement an Angular Material custom form field following this guide: https://material.angular.io/guide/creating-a-custom-form-field-control
But I keep having this error: ERROR Error: mat-form-field must contain a MatFormFieldControl.
According to the documentation:
This error occurs when you have not added a form field control to your form field. If your form field contains a native or element, make sure you've added the matInput directive to it and have imported MatInputModule. Other components that can act as a form field control include , , and any custom form field controls you've created.
But adding a matInput directive to the tags does not change anything. It's like it's blind because the tags are embedded in this new component <example-tel-input>
The mat-form-field:
<mat-form-field>
<example-tel-input placeholder="Phone number" required></example-tel-input>
<mat-icon matSuffix>phone</mat-icon>
<mat-hint>Include area code</mat-hint>
</mat-form-field>
The component with the inputs:
<div [formGroup]="parts" class="example-tel-input-container">
<input class="example-tel-input-element" formControlName="area" size="3" aria-label="Area code" (input)="_handleInput()">
<span class="example-tel-input-spacer">–</span>
<input class="example-tel-input-element" formControlName="exchange" size="3" aria-label="Exchange code" (input)="_handleInput()">
<span class="example-tel-input-spacer">–</span>
<input class="example-tel-input-element" formControlName="subscriber" size="4" aria-label="Subscriber number" (input)="_handleInput()">
</div>
Stackblitz: https://stackblitz.com/edit/angular-9fyeha
What am I missing?