Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9043257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:41:44+00:00 2026-06-16T10:41:44+00:00

I got confused while I was reading the explanation below on emberjs.com. I typed

  • 0

I got confused while I was reading the explanation below on emberjs.com.

I typed the same code as the code below, but it doesn’t give me the same result as the explanation shows.

I think the explanation below is omitted to some extent, so that made me misunderstand and confused.

I want to know the complete code to get the same result shown below to understand fully what the explanations means.

I really appriciate if someone could show me the complete code to get the result shown below.

Thank you very much!

As you’ve already seen, you can print the value of a property by enclosing it in a Handlebars expression, or a series of braces, like this:

My new car is {{color}}.

This will look up and print the View’s color property. For example, if your view looks like this:

App.CarView = Ember.View.extend({
color: ‘blue’
});

Your view would appear in the browser like this:

My new car is blue.

you can aloso specify global paths:

My new car is {{App.carController.color}}.

By the way, here is the code I tried, which doesn’t get me the same result shown in the explation above.

/*----------
app.js
----------*/

var App = Ember.Application.create();

App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
  templateName: 'application'
});

App.CarView = Ember.View.extend({
    color: 'blue',
    templateName: 'car'
});

App.CarController = Ember.Controller.extend();


App.Router = Ember.Router.extend({
    root: Ember.Route.extend({
        index: Ember.Route.extend({
            route: '/'
        })
    })
})

App.initialize();


/*----------
index.html
----------*/

<script type="text/x-handlebars" data-template-name="application">
    <h1>Hello from Ember.js</h1>
</script>

<script type="text/x-handlebars" data-template-name="car">
    My new car is {{color}}.<br />
    My new car is {{App.carController.color}}.
</script>

EDIT:

index.html

<script type="text/x-handlebars" data-template-name="application">

<!-- This Works -->  
{{#view App.CarView}}
    (1)My new car is {{view.color}}.<br />
{{/view}}

<!-- These don't Work -->
(2)My new car is {{view.color}}.<br />
(3)My new car is {{App.CarView.color}}.<br />

(4)My new car is {{App.CarController.color}}.<br />
(5)My new car is {{App.carController.color}}.<br />

<!-- this outlet-area shows what I have in my "car" template -->
{{outlet}}

</script>


<script type="text/x-handlebars" data-template-name="car">

<!-- This color property is defined in App.CarView.-->
(6)My new car is {{view.color}}.<br />

<!-- This color property is defined in App.CarCotroller.-->
(7)My new car is {{color}}.<br />

<!-- These don't work-->
(8)My new car is {{App.CarCotroller.color}}.<br />
(9)My new car is {{App.carCotroller.color}}.<br />

</script>

app.js

var App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
  templateName: 'application'
});


App.CarController = Ember.ObjectController.extend({ 
    color:'blue'
});

App.CarView = Ember.View.extend({   
    color:"blue",
    templateName: 'car'
});


App.Router = Ember.Router.extend({
    root: Ember.Route.extend({
        index: Ember.Route.extend({
            route: '/',
            connectOutlets:function(router){
                router.get('applicationController').connectOutlet('car');
            }     
        })
    })
})

App.initialize();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:41:45+00:00Added an answer on June 16, 2026 at 10:41 am

    Huh, there seems to be an error in the documentation. I will look to it, thanks for pointing it 🙂

    Usually, when using {{color}} in the CarView template, it will lookup to the view’s context, which is its controller by default. The color property should be defined in the controller.

    If you want define and refer a property from the view, then you have to use the view keyword in the template. In your example, {{view.color}} should work.

    EDIT: Concerning the documentation, there is huge WIP see: https://github.com/emberjs/website/tree/doc-refactor. In particular your use case is not here anymore: https://github.com/emberjs/website/blob/doc-refactor/source/guides/templates/handlebars-basics.md

    UPDATE: I think all you questions here are covered in this great instructions: http://trek.github.com/.

    I think it should be enough to understand your points, but I can make short answers that may help you.

    1 Works because you are explicitly creating a CarView here using the {{view}} helper, so using view.color is valid.

    2 Does not work because your are in the scope of the ApplicationView, which has no color property

    3 Does not work because color is a property of a CarView instance not on the CarView class

    4 Same as 3

    5 Ember.js instantiates controllers for you, but they are not properties of the App, but they are properties of the application’s router. So {{App.router.carController.color}} would work (BUT DONT USE IT, VERY BAD PRACTICE)

    6 Works because your are in the CarView’s template, and a color property is defined in the CarView class (and then accessible in the current CarView instance)

    7 Works because it refers the color property defined in the CarController class. As I said, Ember.js instantiates the controller at application initialization time. Later in your code, when calling router.get('applicationController').connectOutlet('car'); Ember.js will create an instance of the CarView class, connect it to the router.carController instance, and display it in the {{outlet}} of the ApplicationView’s template (because your are calling connectOutlet() on the applicationController. As a result, the rendering context of the CarView template is the carController, so when using {{aProperty}}, it means controller.aProperty, and in your case carController.color, which is ‘blue’

    8 Same as 3

    9 Same as 5

    For your last question, as I said, you must never access staticly to the carController instance from the templates 🙂

    Heh, I think that’s all

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mostly i have used $_SESSION , But while reading about Session i got few
I am preparing for SCJP and I got confused while reading about nested types.
Today i was reading about pure function, got confused with its use: A function
I have the following code and got myself confused: I have a query that
While converting a webdesign given as a photoshop file to html+css, I got confused
I'm NOT new to testing, but got really confused with the mess of recommendations
I got some path while working on a project but not able to figure
While reading the code for django/forms/widgets.py, I saw: from util import flatatt To dig
After reading what intra-refresh does, I kinda got confused. I'm encoding for YouTube and
While answering this question I got a bit confused. We all know that this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.