循环,只有获取状态是否为真

时间:2015-03-10 23:31:08

标签: ember.js

我想通过这个视图进行循环,并且只能获得状态,如果仅为真,则如果不为真,则将其显示在底部的另一个视图上。

    <table class="rounded" >
                Unavailable Requests
               {{#each request in model}}
               <ul>
                    <li> Trip ID: {{request.request_id}}</li>
                    <li> Destination: {{request.destination}}</li>
                    <li >Hotel Name: {{request.hotel_name}} - {{#link-to 'rfp' request.id}}view request{{/link-to}}
                    </li>
                        <li>Status: {{status}}</li>
                    <li>Client: {{request.full_name}} - ({{request.user.email}})</li>    
               </ul>
           {{/each}}
    </table>

App.DashboardRoute = App.AuthRoute.extend({
    model: function(){
        return this.store.find('request');
    }
});

先谢谢你们.......

1 个答案:

答案 0 :(得分:0)

您可以将if帮助器放在模板中间,如下所示:

<table class="rounded" >
  Unavailable Requests
  {{#each request in model}}
  <ul>
     <li> Trip ID: {{request.request_id}}</li>
     <li> Destination: {{request.destination}}</li>
     <li >Hotel Name: {{request.hotel_name}} - {{link-to "view request" 'rfp' request}}</li>
     {{#if status}}
        Show the status
     {{else}}
        Show the other view
     {{/if}}
     <li>Client: {{request.full_name}} - ({{request.user.email}})</li>    
   </ul>      
   {{/each}}

</table>