Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

TypeError: Cannot read property 'filter' of undefined at ComboBoxComponent #33

Open
RobertoDavila opened this issue Jan 12, 2018 · 3 comments

Comments

@RobertoDavila
Copy link

Hi.

I found a issue when you load data from a server and you have filter=true, it displays this error:

<combo-box [listData]="brands" (onSelect)="selectValue()" [localFilter]="true" [displayField]="'brand_name'" [valueField]="'brand_id'" [(ngModel)]="brand">

ERROR TypeError: Cannot read property 'filter' of undefined
at ComboBoxComponent

On the component I found the issue:

private loadData() {
    if (!this.remote) {
        if (this.localFilter) {
            this.data = this._initialData.filter((item) => {

If we validate this._initialData as well we will avoid the error:

private loadData() {
    if (!this.remote) {
        if (this.localFilter && this._initialData) {
            this.data = this._initialData.filter((item) => {

Is it possible that you add this to the code?

Regards.

@shochdoerfer
Copy link
Member

Good catch. Thank you for this reporting this issue. Any chance you could provide a pull request with the fix?

@RobertoDavila
Copy link
Author

Hi shoch.

Yes I can fix that, please provide rights for this.

Regards.

@shochdoerfer
Copy link
Member

You can simply fork the repo, create a new branch, apply the fixes, push the branch and then create a pull request out of our pushed branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants