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

fix(select): Cant bind to property of object array without an optionsTemplate #157

Closed
trevordaniels opened this issue Jul 4, 2017 · 5 comments
Assignees
Milestone

Comments

@trevordaniels
Copy link
Contributor

If I try to bind to a specific property on an object array without specifying a template, it throws the following error even when using labelField and valueField

<sui-select #select [formControl]="formControl" [options]="[{'description':1},{'description':2}]" 
[valueField]="description" [labelField]="description" >
     <sui-select-option *ngFor="let option of select.filteredOptions" [value]="option"></sui-select-option>
</sui-select>
ERROR TypeError: text.replace is not a function at SearchService.highlightMatches 

I cant get select to work in plunkr at the moment so no plunkr for this.

@edcarroll edcarroll self-assigned this Jul 4, 2017
@edcarroll edcarroll added this to the 0.9.2 milestone Jul 4, 2017
@edcarroll
Copy link
Owner

I've had a look and this is twofold, firstly you're binding valueField and labelField to the value of description, not the value description (remove the square brackets).

However, this has raised the fact that passing a non-string field will cause an error, so I've updated labelField to always return a string, so if you don't change this code you'll end up with lots of [object Object] in your select which will highlight the issue.

The hotfix release containing these changes will be out soon.

@trevordaniels
Copy link
Contributor Author

trevordaniels commented Jul 4, 2017 via email

@edcarroll
Copy link
Owner

Makes sense, since the 2nd thing was that it's a non-string field so replace wouldn't work. Once I've sorted out the checkbox form stuff I'll get this release out :)

@trevordaniels
Copy link
Contributor Author

trevordaniels commented Jul 4, 2017 via email

@edcarroll
Copy link
Owner

This is now fixed in 0.9.2, the value of the property specified in labelField is automatically cast to a string before running any functions. (This also works for when nothing is specified)

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