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.

md-autocomplete displaying '[object Object]'

See original GitHub issue

Bug:

Md-autocomplete displays [object Object] even though it is passed a string. It displays that only if you select the same object from the dropdown list.

What is the expected behavior?

We should not see [object Object] after selecting the same object from the options.

What are the steps to reproduce?

Here is a Plunker that reproduces the issue: https://plnkr.co/edit/acz2QZHuVo39rdOQ2C3E?p=preview

Select a value from the list. Then click on the input (without typing) and select the same value again (there should be only 1 value in the list - the current one).

gif

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4.3.2 Material 2.0.0-beta.8

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

17reactions
willshowellcommented, Jul 28, 2017

And if you still want to bind the value to state instead of state.name, autocomplete has a displayWith input to control how the selected option gets displayed.

Example: https://plnkr.co/edit/W9vdWaGcoG90LKM8hHgI?p=preview

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 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

Angular AutoComplete is returning value as [Object Object]
To make this work, create a function on your component class that maps the control value to the desired display value. Then bind...
Read more >
How to display and handle objects in mat-auto complete?
If you have array of objects to be shown in <mat-option> ,then you can use displayWith property. By using this property I will...
Read more >
Directives > mdAutocomplete - AngularJS Material
Parameter Type Description md‑search‑text expression expression A model to bind the search query text to. md‑selected‑item object object A model to bind the selected item...
Read more >
[Solved]-ng-autocomplete displaying '[object Object]'-angular.js
[Solved]-ng-autocomplete displaying '[object Object]'-angular.js ... Don't know why you getting this [object object] error but i made one stackblitz example for ...
Read more >
Angular Material - Autocomplete - Tutorialspoint
The md-autocomplete, an Angular Directive, is used as a special input control with an inbuilt dropdown to show all possible matches to a...
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