在我的dom-moule中,我想使用绑定数据ticket.start_time
作为函数的输入并显示函数return(从ticket.start_time
到现在的时间)。< / p>
现在,我只知道如何访问绑定数据,如下所示
<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>
答案 0 :(得分:4)
试试这个
<span>{{myFunc(ticket.start_time)}}</span>
...
<script>
myFunc:function(item){
//some code
return value
}