router.js
Router.map(function() {
this.resource('about');
this.resource('posts',function(){
this.resource('post',{path:':post_id'});
});
});
posts.js
import Ember from 'ember';
var posts = [{
id:1,
title:'EmberJS',
author:{name:'Tom'},
date:new Date(),
excerpt:'Explains very well in starter kit',
body:'Ember is framework for ambitious web apps'
},{
id:2,
title:'AngularJS',
author:{name:'Brian'},
date:new Date(),
excerpt:'NA',
body:'Superheroic JS MVW framework'
}];
export default Ember.Route.extend({
model: function () {
return posts;
}
});
posts.hbs
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<table class="table">
<tr><td> Recent Posts </td></tr>
{{#each}}
<tr><td>
{{#link-to 'post' this}}
{{title}} <small class='muted'> by {{author.name}}</small>
{{/link-to}}
</td></tr>
{{/each}}
</table>
<div class="span9">
{{outlet}}
</div>
</div>
</div>
post.hbs
<h1>{{title}}</h1>
<h2>by{{author.name}} <small class="muted">({{date}})</small> </h2>
<hr>
<div class="intro">
{{body}}
</div>
I am trying to make a blog reading application from Tom’s intro video in ember-cli 0.0.42 environment.
- How do I pass models using this in link-to helper ? Currently if I visit
/posts/1
If I use ember inspector it shows me that model is being set but somehow nothing is being rendered on to the screen. It just renders static content from the templates which is following:
by()