Search code examples
javascriptember.jsember-clihandlebars.js

Ember-CLI Route model data not affecting template


I have an ember route webtest contained within the file routes/webtest.js:

export default Ember.Route.extend({
  model: function() {
    return {
      title: "Does not appear"
    };
  }
});

I have the matching template contained within templates/webtest.hbs

<div class="container">
    <h2>Title: {{title}}</h2>
</div>

when I navigate to the page /webtest in my web browser with ember serve the resulting page has the title: text, but not the text does not appear

I have been to multiple ember pages, and I have the same code working here: http://jsbin.com/neheru/6/edit?html,js,output

The goal is to be able to have a variable accessible from within the template webtest that can be accessed by a route.

FYI I'm trying to get it to the template so I can pass variables to a component


Solution

  • The variable should be {{model.title}}

    You can log out variables from your template with

    {{log title}}
    {{log controller.title}}
    {{log model.title}}
    

    This might help you to debug faster.

    You should then be able to pass data in to our component with something like:

    {{my-component title=model.title}}