1
我在下面試圖做的是使用partials來使我的視圖更加模塊化。不幸的是,這是行不通的。如何將ember.js部分添加到模板?
我得到
Uncaught TypeError: Cannot read property 'view' of undefined in the (compiled) _dataForLeftPane.js @ the following line,
stack1 = foundHelper ? foundHelper.call(depth0, stack1, {hash:{}}) : helperMissing.call(depth0, "outlet", stack1, {hash:{}});
如果我刪除container.hjs聲明的泛音(請參見下面的代碼),並把各自的內容代替,一切正常。但是隻有當我介紹部分時,事情纔會停止。
file: app_router.js.coffee
root: Ember.Route.extend(
index: Ember.Route.extend(
route: '/'
connectOutlets: (router) ->
router.get('applicationController').connectOutlet('container')
router.get('containerController').connectOutlet('dataForLeftPane', 'dataForLeftPane', [{login:'wycats'},{login:'tomdale'}])
router.get('containerController').connectOutlet('dataForRightPane', 'dataForRightPane', [{id:'1234'},{id:'qwerty'}])
)
)
file: views/application_view.js.coffee
App.ApplicationView = Ember.View.extend(
templateName: 'application'
)
App.ContainerView = Ember.View.extend(
templateName: 'a/container'
)
App.DataForLeftPaneView = Ember.View.extend(
templateName: 'a/dataForLeftPane'
)
App.DataForRightPaneView = Ember.View.extend(
templateName: 'a/dataForRightPane'
)
file: templates/a/container.hjs
{{> _a_leftPane}}
{{> _a_rightPane}}
file: templates/a/_leftPane.hbs
{{outlet dataForLeftPane}}
file: templates/a/_rightPane.hbs
{{outlet dataForRightPane}}
file: templates/a/dataForRightPane.hjs
{{#each person in controller}}
{{person.id}}
{{/each}}
file: templates/a/dataForLeftPane.hjs
{{#each person in controller}}
{{person.name}}
{{/each}}