3

Typically, Ember automatically puts the route's model in scope when rendering a handlebars template:

<h1>{{ title }}</h1>

Renders:

<h1>My Title</h1>

For some reason, it's not doing that for me with a particular route. I'm just getting an empty <h1></h1>. However, if I manually put it into scope:

<h1>{{ model.title }}</h1>

Then it works as expected. What might be causing this behavior? My route is basic:

MeetingsShowRoute = Ember.Route.extend
  model: (params) ->
    @store.find('meeting', params.id)

`export default MeetingsShowRoute`

And both the relevant view and controller is empty.

1 Answer 1

2

Your controller is probably extending the controller class, when it should be extending object controller.

MeetingsShowController = Ember.ObjectController.extend ...

Rule of thumb:

No Model backed controller

FooControler = Ember.Controller.extend

Single Model backed controller

FooControler = Ember.ObjectController.extend

Collection Model backed controller

FooControler = Ember.ArrayController.extend
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.