[SOLVED] Changed static model to this.store.findAll()


#1

[UPDATE]

Turned out the I couldn’t do object.property as with the case when it’s an element in array. So I used object.get(‘property’).

[/UPDATE]

Hi everyone,

I’m noob and I created a working app that renders elements in the component. The elements was a simple array in the model() hook which were passed to the component.

>   filteredItems: Ember.computed('optionsFilter,items.length', function() {
>     var items = this.get('items');
>     var optionsFilter = this.get('optionsFilter').toLowerCase();
>     if (optionsFilter != '') {
>       return items.filter(function(item, index, enumerable){
>         var iCode = item.code.toLowerCase().indexOf(optionsFilter);
>         var iDescription = item.description.toLowerCase().indexOf(optionsFilter);
>         return iCode != -1 || iDescription != -1;
>       });
>     } else {
>       return items;
>     }
>   }),

However when I moved my elements to the Database (it's Rails and I followed [this tutorial](https://emberigniter.com/building-user-interface-around-ember-data-app/)) the action when I'm clicking an element isn't working:

>   actions: {
>     onItemClick(item) {
>       var o = this.get('items').removeObject(item);
>       var chosenItems = this.get('chosenItems');
>       chosenItems.pushObject(item);
>       this.set('chosenItems', chosenItems.sortBy('code'));
>     }
>   }

The problem is, 

> this.get('items')

gives

> Class {store: Class, isLoaded: true, manager: Class, isUpdating: false, __ember1472535443472: "ember319"…}

And that class is not the object I got previously, so how can I get properties of it?

Thank you.