nullnullnull
nullnullnull

Reputation: 8189

Ember Handlebars not automatically putting model in scope

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.

Upvotes: 3

Views: 149

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

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

Upvotes: 2

Related Questions