Got TypeError when following official Tutorial: Super Rentals


#1

In the final chapter, when doing autocomplete, I got an error said: TypeError: undefined is not an object (evaluating 'this.set('filteredList').clear') when clearing the city input field.


#2

Push the example to github and provide a link to the repository.


#3

Git repo: https://github.com/daqing/super-rentals

I did a few modifications to the guide.


#4

this.set('filteredList').clear();

You meant this.get('filteredList').clear()


#5

No, it’s this.set('filteredList').clear();, not get()


#6

Do you understand you’re calling set and not passing a value to the setter but treating it like a getter since you’re calling clear on undefined, since set doesn’t return anything?

Please look at my pull request, that’s why I took the time to send it.

Whatever tutorial you’re reading was incorrect, or you misread.


#7

Your PR works, thanks.

So the ember docs is wrong? I have another question: why not just set the property to empty array?

like this: this.set('filteredList', [])