2
最近EmberJS改變了很多(路由器,...),並且我在不到一個月前寫入的代碼現在已被破壞。 我現在遇到的問題之一是我無法手動將控制器綁定到視圖。EmberJS - 手動綁定控制器以查看
我使用requireJS的方式...
所以我用的能夠做這樣的事情(這裏定義爲我的菜單和菜單項的視圖),實際得到的控制器內容和選定的屬性。
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()
})
})
}
);
它看起來像'controller.controllers.menuController'不再存在。 我已經能夠找到容器緩存'container.cache.contoller:menu'中的類,但我的視圖控制器仍然是空的。 我也嘗試App.MenuController
被定義在Application.create({})
任何想法?
在一個側面說明,如果任何人有使用最新的(github上)EmberJS和requireJS工作的例子,我會非常有興趣:)
乾杯。
你好謝恩。 Thx爲答案。我在gthub上看到過你的項目,但是很遺憾我在工作中的窗戶上,看起來yeoman現在還沒有上市......我還發現了看着這個項目的咕嚕咕嚕,我有一個關於這個項目的問題。該字符串獲取應用程序文件夾中的所有js文件,並將其擴展到主要的 – nolazybits
它不是我最初的,它來自https://github.com/tzellman/ember-todos。是的,它基本上執行字符串替換,並添加所有文件。我將這個答案標記爲正確,以便其他人知道它的正確方法,我正在研究一個非yeoman版本,我將添加鏈接並將成爲很多更易使用:) –
對不起太早發佈評論(從我的手機打字)。下面的全部評論 – nolazybits