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.

Feature Request: Evaluate expression instead of [Items]

See original GitHub issue

Currently to utilize ng-select we need to create a variable that needs to be alloted to [items] attribute. Only job of this variable is to act as a source for typeahead. The problem arises when there are multiple ng-select in a view. For each of these ng-select we need to define the input variables.

Instead we can have an attribute like source which evaluates an expression on change in input text. It can also handle async functions (promise). By having this in place we no longer have to handle and define input variables, cleaning up the component.

Incase the library goes this road there would also be a need to have a [debounce] attribute or a way to handle the same in component.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
anjmaocommented, Feb 1, 2018

Hi @shyamal890. Thanks for reporting. I was thinking about allowing [items] to accept Observable but I realised that you can use async pipe

source$: Observable<User[]>;
ngOnInit() {
     this.source$ = this.http.get('/users');
}
<ng-select [items]="source$ | async"></ng-select>

For all custom filtering needs there is [typeahead] input which allows you to implement any custom filtering you want on your side (debounce, distincUntilChanges, …). There are few improvements left for client side filtering like specifying which fields to search.

  1. By allowing to pass data source expression ng-select will need to handle actual data retrieval this means you need to think what happens when error occurs, should ng-select handle it or not. This will add more complexity.

I’m adding this to version 2.0.0 milestone for now.

0reactions
varnastadeuscommented, May 18, 2018

In that case I am closing this issue, since having expression as @Input would result in this issues:

  • Expression will mutate reference all the time and it will trigger cd
  • Expression will stay immutable so user would need to mutate it which makes no sense
Read more comments on GitHub >

github_iconTop Results From Across the Web

feature request: eval · Issue #384 · stedolan/jq - GitHub
Currently, a jq expression can be conveniently represented as a JSON string in a JSON object, but there does not appear to be...
Read more >
Feature Request - Comments inside Application Form...
Dear Product Developers, I would like to request a simple feature to allow commenting inside Application Formula/Expression please?
Read more >
unable to evaluate expression whilst debugging
When debugging asp.net code (running against IIS, and using Visual studio 2013) and in a breakpoint and trying to evaluate a variable using...
Read more >
Examine suspended program | IntelliJ IDEA Documentation
The simplest way to evaluate an expression is to point at it in the code. Although this is the quickest way, it cannot...
Read more >
Python eval(): Evaluate Expressions Dynamically - Real Python
To evaluate a string-based expression , Python's eval() runs the ... You can use compile() to supply code objects to eval() instead of...
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