2016-12-25 3 views
2

私のdom-mouleでは、バインドされたデータticket.start_timeを関数への入力として使用し、関数の戻り値を表示したいとします(これは、 。バインドされたデータをポリマーの関数入力として使用する方法

今、私はバインドされたデータにアクセスする方法を知っている

<li><span>{{ticket.start_time}} has lapsed</span> 

を次のように欠けている部分は、この機能を起動する方法を機能

  • からticket.start_timeにアクセスする方法を

    • です

    完全なコードは次のとおりです。

    <dom-module id="todo-app">               
    <template>                  
    <ul>  
        <template is="dom-repeat" items="[[reply.tickets]]" as="ticket">    
        <style>                  
        span[done]{                 
         text-decoration: line-through;           
        }                   
        </style>                  
        <li><span done$={{ticket.end_time}}>{{ticket.id}}: {{ticket.detail}}, {{ticket.start_time}} has lapsed</span> 
        </template> 
    </template> 
    </ul> 
    
    <iron-ajax                 
        auto=true                 
        id="requestData"               
        url="/data"                
        handleAs="json"               
        on-response="handleResponse">            
    </iron-ajax>                 
    </template>                 
    
        <script>                  
        Polymer({                 
         is: "todo-app",               
         properties: {                
         reply: {                 
          type: Object               
         }                  
         },                   
         handleResponse: function (data){           
         this.reply= data.detail.response;          
         }                   
        });                   
        </script>                  
    </dom-module> 
    
  • 答えて

    4

    <span>{{myFunc(ticket.start_time)}}</span> 
    ... 
    <script> 
        myFunc:function(item){ 
        //some code 
        return value 
    } 
    
    これを試してみてください
    関連する問題