Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeahead breaks if typeahead property receives NULL value #4417

Closed
ghost opened this issue Jun 7, 2018 · 3 comments
Closed

Typeahead breaks if typeahead property receives NULL value #4417

ghost opened this issue Jun 7, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 7, 2018

The typeahead directive breaks if the [typeahead] property receives a NULL value (with NullPointerException). This happens since my async data service returns NULL instead of [] if no search results were found.

I'm wondering why NULL is not a valid value? In my opinion, the directive should catch undefined values by itself.

ERROR TypeError: Cannot read property 'slice' of null
    at TypeaheadDirective.push../node_modules/ngx-bootstrap/typeahead/typeahead.directive.js.TypeaheadDirective.prepareMatches (typeahead.directive.js:306)
...

ngx-bootstrap: 3.0.0
Angular: 6.0.1

@pankmuze
Copy link

pankmuze commented Jun 9, 2018

I am also facing the same issue. When there is nothing to return from the database for the API call, it is throwing the slice error and then I am unable to search anything anymore.

Can someone help in this?

@pankmuze
Copy link

pankmuze commented Jun 9, 2018

Can we use the typeaheadNoResults in anyway here?

@pankmuze
Copy link

Found a workaround. For the empty return value, I am making the API return an empty object, so the slice error is not coming up anymore.

This empty object I have renamed as "No record found", so that when it is seen in the UI, it looks as though it is not returning anything.

In the TypeaheadOnSelect method, I am clearing the input field :-)

Hope this help others who are facing this issue

@Domainv Domainv closed this as completed Dec 7, 2018
valorkin pushed a commit that referenced this issue Dec 21, 2018
…es NULL (#4957)

* fix(typeahead): Typeahead breaks if typeahead property receives NULL

* fix(typeahead): restore typehead-directive file

* feat(typeahead): add tests for new func

* fix(typeahead): rework existing pr

Fixes #4417
leo6104 pushed a commit to leo6104/ngx-bootstrap that referenced this issue Oct 10, 2019
…es NULL (valor-software#4957)

* fix(typeahead): Typeahead breaks if typeahead property receives NULL

* fix(typeahead): restore typehead-directive file

* feat(typeahead): add tests for new func

* fix(typeahead): rework existing pr

Fixes valor-software#4417
IraErshova pushed a commit to IraErshova/ngx-bootstrap that referenced this issue Jan 20, 2020
…es NULL (valor-software#4957)

* fix(typeahead): Typeahead breaks if typeahead property receives NULL

* fix(typeahead): restore typehead-directive file

* feat(typeahead): add tests for new func

* fix(typeahead): rework existing pr

Fixes valor-software#4417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants