如何将ember.js部分添加到模板?

如何将ember.js部分添加到模板?,ember.js,handlebars.js,Ember.js,Handlebars.js,下面我尝试使用partials使我的视图更加模块化。不幸的是,这不起作用 我明白了 Uncaught TypeError: Cannot read property 'view' of undefined in the (compiled) _dataForLeftPane.js @ the following line, stack1 = foundHelper ? foundHelper.call(depth0, stack1, {hash:{}}) : helperMissing.c

下面我尝试使用partials使我的视图更加模块化。不幸的是,这不起作用

我明白了


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: templates/parentView.hjs
{{view.someProperty}}
//here is the parent view calling a template
{{view "App.templateView" contentBinding="view.content"}}
这将插入指定的App.templateView,并将其内容绑定到呈现视图的传递内容属性。您可以将任何想要的内容作为templateViews内容传递

这很可能是你想做的,但我不确定我是否正确阅读了你的问题

此外,这在语义上接近于在rails中使用传递的本地。因此,我认为这可能是您正在寻找的解决方案,因为您指的是“部分”

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}}
file: templates/parentView.hjs
{{view.someProperty}}
//here is the parent view calling a template
{{view "App.templateView" contentBinding="view.content"}}