在{{each}}帮助器中,Ember:{{link-to}}帮助器错误

Vin*_*ier 2 ember.js

link-to助手返回以下错误:

Uncaught Error: each doesn't match link-to - 5:10
Run Code Online (Sandbox Code Playgroud)

模板:

<script type="text/x-handlebars" id="actions">
  <div class='container-fluid'>
    <div class="row">    <!--  -->
      <div class="col-md-6 col-lg-4">    <!--  -->
        {{#each action in model}}
          {{link-to 'action' action}}{{action.id}}{{/link-to}}
        {{/each}}
        {{outlet}}
      </div>       
    </div>
  </div> 
</script>
Run Code Online (Sandbox Code Playgroud)

路由器:

App.Router.map(function() {
  this.resource('application', function() {
    this.resource('actions', function() {
      this.resource('action', { path: '/:action_id'});
    });  
});
Run Code Online (Sandbox Code Playgroud)

路线:

App.ActionsRoute = Ember.Route.extend({
  model: function() {
    return this.store.findAll('action');
    //return this.modelFor('user').get('actions');
  },

  setupController: function (controller, model) {
    controller.set('model', model);
  },

});  
Run Code Online (Sandbox Code Playgroud)

我找不到有什么不对.

Kar*_*ren 6

这是一个非常小的错误.当使用块帮助程序时,each或者link-to你需要在前面用#调用它们,就像你已经完成的那样{{#each}}.由于您在启动时缺少该功能link-to,因此解析器会查看{{/link-to}}并注意到它当前正在使用each-block且不匹配.只需在您的首发'link-to'前添加一个#,它应该可以正常工作.

{{#each action in model}}
    {{#link-to 'action' action}}{{action.id}}{{/link-to}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)