EmberJS - 手动绑定控制器进行查看 [英] EmberJS - Manually bind controller to view
问题描述
我现在有一个问题是我无法手动将控制器绑定到视图。
我正在使用requireJS。
所以我曾经能够做这样的事情(这里定义我的菜单和菜单项的视图),实际获取控制器的内容和选择属性。
定义
(
'app / common / views / menu',
[
'text!app / common / templates / menu.hbs',
'ember'
],
/ **
*菜单视图
*
* @param模板
* @returns类
* /
函数(模板)
{
返回Ember.View.extend
({
controllerBinding:'controller.controllers.menuController',
selectedBinding:'controller.selected',
template:Ember.Handlebars.compile(template),
NavItemView:Ember .View.extend
({
tagName:'li',
classNameBindings:'isActive:active'.w(),
isActive:function()
{
return this.get ('item')=== this.get('parentView.selected');
} .property('item','parentView.selected')。cacheable()
})
})
}
);
看起来像controller.controllers.menuController不再存在。
我已经能够在容器缓存container.cache.contoller:menu中找到该类,但是我的视图控制器仍然为空。
我也试过在code> Application.create({})中定义 App.MenuController
p>
任何想法?
在旁注中,如果有人使用最新的(github)EmberJS和
这是最新的TODOMVC Ember / require.js! :D我会回来更明确地回答你的问题:
https://github.com/sh4n3d4v15/ember-todos
Lately EmberJS changed a lot (Router, ...) and the code I have started to write less than a month ago is now broken. One of the issue I have right now is I am not able to manually bind the controller to the view.
I am using requireJS by the way...
So I used to the able to do something like this (here to define the view for my menu and the menu items), to actually get the Controller content and selected properties.
define
(
'app/common/views/menu',
[
'text!app/common/templates/menu.hbs',
'ember'
],
/**
* Menu view
*
* @param template
* @returns Class
*/
function( template )
{
return Ember.View.extend
({
controllerBinding : 'controller.controllers.menuController',
selectedBinding: 'controller.selected',
template: Ember.Handlebars.compile( template ),
NavItemView: Ember.View.extend
({
tagName: 'li',
classNameBindings: 'isActive:active'.w(),
isActive: function()
{
return this.get('item') === this.get('parentView.selected');
}.property('item', 'parentView.selected').cacheable()
})
})
}
);
It looks like 'controller.controllers.menuController' doesn't exists anymore.
I have been able to find the class in the container cache 'container.cache.contoller:menu' but my view controller will still be null.
I have also try App.MenuController
being defined in the Application.create({})
Any idea?
On a side note, if anybody has a working example using the latest (github) EmberJS and requireJS I would be VERY interested :)
Cheers.
Here is the latest TODOMVC Ember/require.js! :D I'll come back to answer your questions more explicitly:
https://github.com/sh4n3d4v15/ember-todos
这篇关于EmberJS - 手动绑定控制器进行查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!