Computed property in model hook


#1

Hi, guys…

Suppose we have such a route, where

Ember.Route.extend({
    data: [],
    model: {
        return {
            filterData: Ember.computed.filter("data.[]", function(
                // just example
                return true;
            ))
        }
    }
    actions: {
        loadMoreData: function() {
            Ember.$.ajax.get("/api/data").then(function(response) {
                this.data.pushObjects(response.data);
            })
        }
    }
})

So, of course, that doesn’t work cause there is no field “data” in object, returning from model hook.
But I was sure that proper pattern is to make all server requests from route. And that way, I can’t understand how I can provide it available in a template scope.

Any ideas? How do you organize code for routes with pagination and sorting on the page?


#2

My Sorting and Pagination example is perhaps interesting: