I have following code:
<ion-content>
<ion-list>
<ion-item ng-repeat="x in names|orderBy:'order_id'">
{{ x.order_id + ', ' + x.table_id+', '+x.name+', '+x.phone+', '+x.address+', '+x.remark+', '+myFunction(x.ctime)}}
</ion-item>
</ion-list>
</ion-content>
I want to call myFunction and get the returned value, but it doesn't work.
<script type="text/javascript">
function myFunction(ctime) {
alert("Hello World!");
// create a new javascript Date object based on the timestamp
// multiplied by 1000 so that the argument is in milliseconds, not seconds
var date = new Date(ctime*1000);
// hours part from the timestamp
var hours = date.getHours();
// minutes part from the timestamp
var minutes = "0" + date.getMinutes();
// seconds part from the timestamp
var seconds = "0" + date.getSeconds();
// will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
console.log("debug",formattedTime);
return formattedTime;
}
</script>
I wonder to know where the problem is. thanks.
<ion-item ng-repeat="x in names|orderBy:'order_id'" ng-init="myFunction(x.ctime)">returnstatement? this code never execute