ホームページがブログ投稿のリストを表示するブログを作成しているとします。私の質問は、各子投稿ビューにモデルを渡す方法ですか?
コレクションを反復処理する index.hbs があります
{{#forEach models}}
{{view "post_view" model=value model_name="story"}}
{{/forEach}}
私はpost_view.jsを持っています
var BaseView = require('./base');
module.exports = BaseView.extend({
className: 'post_view',
initialize: function() {
console.log(this.model); //undefined
console.log(this.options.model); //undefined on client, logs model attributes on server
}
});
module.exports.id = 'post_view';
しかし、モデルがpost_view.js内に設定されていないようです。{{json value}}
ループ内で実行すると{{forEach}}
、JSON 化された出力が表示されます。モデルを渡すために何をする必要がありますか?ビュー内で手動で構築する必要がありますか? ありがとう!