以下で私がやろうとしているのは、パーシャルを使用してビューをよりモジュール化することです。残念ながら、これは機能しません。
私は得る
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}}