Here is one of the implementations in which the properties of the model and the content of the controller are clearly separated by the setupController hook of the corresponding route.
I have a list of balls with different colors in a separate file.
balls.js
[ {"id":1,"color":"darkred"}, {"id":2,"color":"lightred"}, {"id":3,"color":"darkgreen"}, {"id":4,"color":"lightgreen"}, {"id":5,"color":"darkblue"}, {"id":6,"color":"lightblue"} ]
App.js
App = Ember.Application.create(); App.Router.map(function() { this.resource('balls',{path:"/balls/:color"}); }); App.BallsRoute = Ember.Route.extend({ model: function(params) { return params; }, serialize:function(model){return {color:model.color}}, setupController:function(cont,model){ var balls=Em.A(); if(!App.Balls) App.Balls=$.getJSON("/start/js/balls.js"); App.Balls.then(function(json){ var re=new RegExp(model.color) balls.setObjects(json); var filtered =balls.filter(function(o,i){return re.test(o.color);}); cont.set('content',filtered); }); } }); App.ApplicationController=Em.Controller.extend({ searches:[{color:"red"},{color:"blue"},{color:"green"}] }); App.BallsController=Em.ArrayController.extend({ });
HTML
<script type="text/x-handlebars"> <h2>Welcome to Ember.js</h2> <nav> {{#each item in searches}} {{#link-to "balls" item}} {{item.color}} {{/link-to}} {{/each}} </nav> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="balls"> <ul> {{#each controller}} <li>{{color}}</li> {{/each}} </ul> </script>
I do not use Ember data, as it is not convenient for me.
Pls check this bin
source share