如何在Ember.js应用程序中检索我的视图的“当前实例”(定义为TextView
)?Ember.js中的CustomView的当前实例
如果我正确地得到它,路由器管理用正确的上下文实例化textView
(我可以在手柄模板中作为{{content}}
访问它)。基本上,我在我的消息应用程序中有几个联系人,我需要为他们每个人保存一些消息。
查看:
App.TextView = Ember.View.extend({
templateName : 'text',
messages : [],
});
路由器:
send : Ember.Route.extend({
route:'/send',
connectOutlets:function (router) {
var conversationController = router.get('conversationController'),
contact = conversationController.get('content');
// contact is my context, it's ok here
conversationController.connectOutlet('text', contact);
}
)};
每次调用'conversationController.connectOutlet('text',contact)'后,都会创建并返回一个TextView实例。 在这里被警告,我不知道它是否是预期的,但消息属性将在这里的所有视图实例之间共享。 – 2012-08-16 15:15:10
'conversationController.get('view')'将会返回'TextView'的当前实例。 – Manoharan 2012-08-17 04:41:57