Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 删除每一条语句_Loops_Ember.js_Ember Data - Fatal编程技术网

Loops 删除每一条语句

Loops 删除每一条语句,loops,ember.js,ember-data,Loops,Ember.js,Ember Data,我对余烬的每一句话都有点困难。我有一个用户,他有许多与他相关的主题,我想在列表中显示这些主题。这是我所拥有的,但它没有呈现任何内容: <script type = "text/x-handlebars" id = "user"> {{#if deleteMode}} <div class="confirm-box"> <h5>Really?</h5> <button {

我对余烬的每一句话都有点困难。我有一个用户,他有许多与他相关的主题,我想在列表中显示这些主题。这是我所拥有的,但它没有呈现任何内容:

<script type = "text/x-handlebars" id = "user">

    {{#if deleteMode}}
        <div class="confirm-box">
            <h5>Really?</h5>
            <button {{action "confirmDelete"}}> yes </button>
            <button {{action "cancelDelete"}}> no </button>
        </div>
    {{/if}}

    <h3>Name: {{name}}</h3>
    <h3>Email: {{email}}</h3>
    <h3>Subjects:</h3>
    <ul>
        {{#each subject in this.user}}
            <li>
                {{subject.name}}
            </li>
        {{/each}}
    </ul>

    <button {{action "edit"}}>Edit</button>
    <button {{action "delete"}}>Delete</button> 

    {{outlet}}

</script>
还有我的主题模型-

App.Subject = DS.Model.extend({
  name: DS.attr('string'),
  users: DS.hasMany('user')
});

有什么建议吗?

用户是您的范围,因此您可以在集合中发送

   {{#each item in collection}}
给你

   {{#each subject in subjects}}
        <li>
            {{subject.name}}
        </li>
    {{/each}}
{{{#主题中的每个主题}
  • {{subject.name}
  • {{/每个}}
    你做错了。您处于当前用户的上下文中,因此可以访问当前用户的主题。基本上,您需要做的是:

    {{#each subject in subjects}}
        <li>
            {{subject.name}}
        </li>
    {{/each}}
    
    {{{#主题中的每个主题}
    
  • {{subject.name}
  • {{/每个}}

    {{{#每个主题}
    
  • {{this.name}}
  • {{/每个}}
    您是否为控制器提供了正确的型号?如果你这样做了,你能在jsbin上发布一个你的问题的例子,这样我们就可以追溯你的问题了吗?
    {{#each subject in subjects}}
        <li>
            {{subject.name}}
        </li>
    {{/each}}
    
    {{#each subjects}}
        <li>
            {{this.name}}
        </li>
    {{/each}}