Skip to content

ERROR RuntimeError: NG0318: '<input>' is an invalid control host. The host must be a native form control (such as <input>', '<select>', or '<textarea>') or a custom form control component with a 'value' or 'checked' model. #64362

Closed

Description

@timdeschryver

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

Yes

Description

Upgrading from 21.0.0-next.5 to 21.0.0-next.6 results in runtime errors when using signal forms. Previously working forms are throwing the following error:

ERROR RuntimeError: NG0318: '<input>' is an invalid control host. The host must be a native form control (such as <input>', '<select>', or '<textarea>') or a custom form control component with a 'value' or 'checked' model.

Either the implementation or the error message contains a mistake, because input is a native form control.

The form looks as follows:

<form novalidate>
	<input [control]="customerForm.firstName" />
</form>

Please provide a link to a minimal reproduction of the bug

timdeschryver/Sandbox#53

Please provide the exception or error you saw

ERROR RuntimeError: NG0318: '<input>' is an invalid control host. The host must be a native form control (such as <input>', '<select>', or '<textarea>') or a custom form control component with a 'value' or 'checked' model.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.0.0-next.7
Angular           : 21.0.0-next.7
Node.js           : 22.16.0
Package Manager   : pnpm 10.18.1
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.0-next.6     │ 21.0.0-next.6     │
│ @angular/cli              │ 21.0.0-next.7     │ 21.0.0-next.7     │
│ @angular/common           │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ @angular/compiler         │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ @angular/compiler-cli     │ 21.0.0-next.7     │ 21.0.0-next.7     │
│ @angular/core             │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ @angular/forms            │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ @angular/platform-browser │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ @angular/router           │ 21.0.0-next.7     │ ^21.0.0-next.6    │
│ ng-packagr                │ 21.0.0-next.4     │ 21.0.0-next.4     │
│ rxjs                      │ 7.8.2             │ ~7.8.2            │
│ typescript                │ 5.9.3             │ 5.9.3             │

Anything else?

This also occurs when using select, or textarea elements.

Activity

  1. JeanMeche commented on Oct 11, 2025

    @JeanMeche
    Member

    Could you please provide a minimal repro of this ? I couldn't reproduce it with the example you give and the next.7 version.

  2. added
    needs reproduction
    on Oct 11, 2025
  3. timdeschryver commented on Oct 11, 2025

    @timdeschryver
    ContributorAuthor

    @JeanMeche of course, sorry my laziness 😅
    Here's a simple repo that has the same error, https://github.com/timdeschryver/signal-forms-repro

    The culprit is a directive that's added on the input with the signal control.
    When ViewContainerRef is injected within the directive, then the problem occurs.

  4. JeanMeche commented on Oct 11, 2025

    @JeanMeche
    Member

    Cool, thanks for the repro.
    So yeah the minimal repro is following:

    @Directive({
      selector: 'input',
    })
    export class InputDirective {
      vcr = inject(ViewContainerRef);
    }
    
    @Component({
      selector: 'app-root',
      imports: [Control, InputDirective],
      template: ` <input [control]="f.firstName" /> `,
    })
    export class App {
      f = form(signal({ firstName: 'John' }));
    }
    
  5. added and removed
    needs reproduction
    on Oct 11, 2025
  6. added this to the needsTriage milestone on Oct 11, 2025
  7. self-assigned this
    on Oct 12, 2025
  8. added 2 commits that reference this issue on Oct 12, 2025
    2a55814
    bd84966
  9. added 8 commits that reference this issue on Oct 13, 2025
    cc4fc57
    45aa8bb
    9fdf50c
    5f60bfa
    e339787
    31f67a9
    e25de25
    4eb01eb
  10. added 2 commits that reference this issue on Oct 13, 2025
    810125d
    a684c16
  11. added a commit that references this issue on Oct 14, 2025
    ab415f3
  12. DuncanFaulkner commented on Oct 17, 2025

    @DuncanFaulkner
    Contributor

    this was working on 21.0.0-next.6 but was broken in next.7 and next.8 (next.9 of Material)

    <mat-form-field>
        <mat-label for="emailType">Email type</mat-label>
        <mat-select id="emailType" [field]="profileForm.emailType" required>
          @for (emailType of emailTypes ; track emailType.value ) {
          <mat-option [value]="emailType.value">{{emailType.viewValue}}</mat-option>
          }
        </mat-select>
        @if(profileForm.emailType().errors().length > 0) {
        <mat-error>
          @for(error of profileForm.emailType().errors(); track error) {
          <span>{{ error.message }}</span>
          }
        </mat-error>
        }
      </mat-form-field>
    
    Image
  13. JeanMeche commented on Oct 17, 2025

    @JeanMeche
    Member

    @DuncanFaulkner can you open a new issue with a stackblitz repro. The issue mentioned by OP has been fixed.

  14. angular-automatic-lock-bot commented on Nov 17, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  15. locked and limited conversation to collaborators on Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions