如何在emberjs车把中打破{{#each}}

时间:2016-12-09 10:16:44

标签: ember.js handlebars.js

我想知道如何在emberjs把手中breakcontinue {{#each}} loop

 <ul>
   {{#each people}}
     //if name == 'xyz' i want to break the loop
     // else list the name
     <li>{{name}}</li>
   {{/each}}
 </ul>

我知道如何使用条件,如下所示

   {{#if (eq name "xyz")}}
        bye
    {{else}}
        {{name}}
    {{/if}}

1 个答案:

答案 0 :(得分:3)

break阻止的emberjs把手中没有continueeach。所以我建议你通过计算属性来修改people数组。

peopleLimited:Ember.comptued('people.[]',function(){
 let result = [];
 //implement your logic here to cut down people array.
 return result;
});