question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use MatAutocomple without MatInput

See original GitHub issue

I want to use MatAutocomplete on a bootstrap-styled input. Unfortunately, being able to use MatAutocomplete requires surrounding the input with a mat-form-field and giving the input itself a matInput-directive.

I was wondering if it is possible to avoid using

  • mat-form-field
  • matInput
  • or at least use them in a “headless-mode” so they handle things like focus and model change subscriptions, but do not edit the template

The original mat-input is just too big and too interactive for many use cases. I am sure many people would like to replace it’s style.

By the way, if the matInput directive is missing, you get the very misleading message

UiBootstrapSearchComponent.html:8 ERROR Error: mat-form-field must contain a MatFormFieldControl.
    at getMatFormFieldMissingControlError (form-field.es5.js:119)
    at MatFormField.push.../../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField._validateControlChild (form-field.es5.js:771)
    at MatFormField.push.../../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField.ngAfterContentInit (form-field.es5.js:453)
    at callProviderLifecycles (core.js:22409)
    at callElementProvidersLifecycles (core.js:22390)
    at callLifecycleHooksChildrenFirst (core.js:22380)
    at checkAndUpdateView (core.js:23311)
    at callViewAction (core.js:23548)
    at execComponentViewsAction (core.js:23490)
    at checkAndUpdateView (core.js:23313)

even though it is matInput and not [formControl] missing

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Apr 2, 2019

Since you removed the matInput, you also have to remove the mat-form-field around it. matInput is used as a way to tell mat-form-field that an input is tied to it.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 10, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Angular Material mat-autocomplete without ReactiveForm
1. when something is typed in the mat-input , make an Ajax call to retrieve a list of users · 2. Display the...
Read more >
Use MatAutocomple without MatInput · Issue #15684 - GitHub
I want to use MatAutocomplete on a bootstrap-styled input. Unfortunately, being able to use MatAutocomplete requires surrounding the input ...
Read more >
Autocomplete | Angular Material
The autocomplete is a normal text input enhanced by a panel of suggested options. link Simple autocomplete. Start by creating the autocomplete panel...
Read more >
Autocomplete overview - StackBlitz
<input matInput placeholder="State". aria-label="State" [matAutocomplete]. ="auto" [formControl]="stateCtrl"> ... Use of this source code is governed by an.
Read more >
Angular 13 Autocomplete Tutorial with Angular Material
Today we are going to create Autocomplete in Angular 11 using ... to use such as MatAutocompleteModule and MatInputModule directives.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found