通知ドロップダウンなど、ルートを使用していないページ上のグローバル セクションを管理する方法について混乱しています。
通知ドロップダウンは常に表示され、それに応じて更新する必要があります。
これは私が試したものです。
で通知を設定するApplcationContoller
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('notifications', this.store.find('notification'));
}
});
そして、それらをApplicationTemplate
<script type="text/x-handlebars">
{{#each notifications}}
Message: {{message}}
{{/each}}
<script>
これは機能しますが、通知に少なくとも独自のコントローラーを持たせたいので、正しくないようです。
コントローラーを通知に割り当てる方法がわからなかったので、通知用のビューを作成し、このようにコントローラーを割り当ててみました。
通知用のビューを作成しました
App.NotificationsView = Ember.View.extend({
controller: App.NotificationsController.create(),
templateName: 'notifications'
});
通知テンプレートを作成しました
<script type="text/x-handlebars" data-template-name="notifications">
Notifications
</script>
作成したNotificationsController
App.NotificationsController = Ember.Controller.extend({
init: function() {
this._super();
this.set('content', this.store.find('notification'));
}
});
そして、次のエラーが表示されます。
Uncaught TypeError: Cannot call method 'find' of null
明らかにそれthis.store
はnull
全体として、この種の機能を実現するための最良の方法は何ですか?