ng-lightning - data object is undefined on lookup

后端 未结 2 378
名媛妹妹
名媛妹妹 2021-01-24 08:53

I\'m working with the Lookup component and am getting an error that my data object is undefined and thus cannot .filter(). Code is below:

getAllAccounts() {
             


        
相关标签:
2条回答
  • 2021-01-24 09:07

    Just a small comment regarding this ;-)

    It's perhaps better to wrap your lookup method instead of using the bind method in TypeScript because you will lose type checking.

    Something like this:

    this.lookup = (query) => {
      this.lookup(query);
    };
    

    See this link for more details:

    • https://basarat.gitbooks.io/typescript/content/docs/tips/bind.html
    0 讨论(0)
  • 2021-01-24 09:11

    Answered by @bekos on the Gitter. Need to add binding to component constructor:

    constructor(elementRef:ElementRef, private _quickAddService:QuickAddService) { 
        this.visible = true;
    
        this.lookup = this.lookup.bind(this);
    }
    
    0 讨论(0)
提交回复
热议问题