我正在设置一个当前看起来像这样的测试 Ember 应用程序:
App = window.App = Ember.Application.create();
App.Router.map(function() {
this.resource('subscriptions', { path: '/' }, function() {
this.route('media', { path: '/:photo_id' });
});
});
App.SubscriptionsRoute = Ember.Route.extend({
model: function() {
return App.Subscription.findAll();
}
});
App.SubscriptionsMediaRoute = Ember.ObjectController.extend({
model: function(params) {
return App.Subscription.find(params.photo_id);
},
serialize: function(model) {
return { photo_id: model.photo_id };
}
});
App.Subscription = Ember.Object.extend();
App.Subscription.reopenClass({
findAll: function(id) {
var subs = Ember.A([
App.Subscription.create({ id: 1, photo_id: 221, name: "Test 1" }),
App.Subscription.create({ id: 2, photo_id: 222, name: "Test 2" }),
App.Subscription.create({ id: 3, photo_id: 223, name: "Test 3" })
]);
return subs;
}
});
这个想法是显示订阅列表,每个订阅最终都会链接到一些媒体(图像)以在访问正确路线时显示,我正在显示订阅列表,如下所示:
<script type="text/x-handlebars" data-template-name="subscriptions">
<div class="col-3">
<div class="list-group">
{{#each subscription in controller}}
{{#linkTo 'subscriptions.media' subscription classNames="list-group-item"}}
{{subscription.name}}
{{/linkTo}}
{{/each}}
</div>
</div>
<div class="col-9">
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="subscriptions/media">
Display photos here -- NOT RENDERING --
</script>
一切看起来都很好,但是由于某种原因subscriptions/media
,当我单击链接时,我的模板没有出现在订阅出口上,这是一个 jsbin 供参考:http: //jsbin.com/ubumag/3/edit
任何指针?提前致谢。