In the following example, using the new Router v2 API, the ember application behaves as expected with one exception. When hovering over the dynamically created links, using a registered #linkTo Handlebars helper the id of the user is null in the url.
Clicking the link transitions to the proper state, but the url is still 'null'.
What gives? Is there a simple convention I am missing?
App = Ember.Application.create({
autoinit: false,
rootElement: "body"
});
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter.create({})
});
App.User = DS.Model.extend({
email: DS.attr('string'),
username: DS.attr('string')
});
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.ApplicationController = Ember.Controller.extend();
App.HomeController = Ember.Controller.extend({
});
App.UserController = Ember.ObjectController.extend({
});
App.Router.map(function(match) {
match("/").to("home");
match("/users/:user_id").to("user");
});
App.HomeRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('users', App.User.find());
}
});
App.UserRoute = Ember.Route.extend({
setupControllers: function(controller, user) {
controller.set('content', user);
}
});
App.initialize();
<script type="text/x-handlebars" data-template-name="home">
{{#if users.isLoaded}}
{{#each item in users}}
<div class="user">
{{item.email}}
</div>
<div class="user">
{{#linkTo user item}}
{{item.username}}
{{/linkTo}}
</div>
{{/each}}
{{else}}
<p class="loading">Loading Users</p>
{{/if}}
</script>
<script type="text/x-handlebars" data-template-name="user">
<div class="user">
<h3>{{username}}</h3>
<p class="email">{{email}}</p>
</div>
</script>