Skip to content

Commit 7b1965d

Browse files
committed
Prefix the model property in templates
1 parent dc0b76c commit 7b1965d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

source/controllers/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ Your template would bind to these properties in the `blog-post`
1919
template:
2020

2121
```app/templates/blog-post.hbs
22-
<h1>{{title}}</h1>
23-
<h2>by {{author}}</h2>
22+
<h1>{{model.title}}</h1>
23+
<h2>by {{model.author}}</h2>
2424
2525
<div class='intro'>
26-
{{intro}}
26+
{{model.intro}}
2727
</div>
2828
<hr>
2929
<div class='body'>
30-
{{body}}
30+
{{model.body}}
3131
</div>
3232
```
3333

3434
In this simple example, we don't have any display-specific properties
35-
or actions just yet. For now, our controller just acts as a
35+
or actions just yet. For now, our controller's `model` property just acts as a
3636
pass-through (or "proxy") for the model properties. (Remember that
3737
a controller gets the model it represents from its route handler.)
3838

@@ -42,18 +42,18 @@ first modify our template to show the body only if the value of a
4242
new `isExpanded` property is true.
4343

4444
```app/templates/blog-post.hbs
45-
<h1>{{title}}</h1>
46-
<h2>by {{author}}</h2>
45+
<h1>{{model.title}}</h1>
46+
<h2>by {{model.author}}</h2>
4747
4848
<div class='intro'>
49-
{{intro}}
49+
{{model.intro}}
5050
</div>
5151
<hr>
5252
5353
{{#if isExpanded}}
5454
<button {{action 'toggleProperty' 'isExpanded'}}>Hide Body</button>
5555
<div class='body'>
56-
{{body}}
56+
{{model.body}}
5757
</div>
5858
{{else}}
5959
<button {{action 'toggleProperty' 'isExpanded'}}>Show Body</button>
@@ -112,7 +112,7 @@ user navigates around the page.
112112

113113
For convenience, Ember.js provides an `Ember.ArrayController` that proxies
114114
properties from an Array. If your controller is an `ArrayController`, you can
115-
iterate directly over the controller using `{{#each controller as |item|}}`. This
115+
iterate over the model using `{{#each model as |item|}}`. This
116116
keeps the template from having to know about how the controller is implemented
117117
and makes isolation testing and refactoring easier.
118118

0 commit comments

Comments
 (0)