前言:
最近在做前端的项目,刚开始做还是很羞涩的样子,不过好在有百度下大神的无私奉献还有我们家欢哥的热情帮助,这个问题解决了,宝宝只负责记录一下(虽然是我的任务)下面进入主题:
之前:
之后:
之前我是在html中试着调ts中的方法,保存之前整个界面都没了,虽然你挺难看的但是这也太给面子了;屡试无效那就请我们家欢哥来吧(明智之举),欢哥帮我解决完问题还特别好的告诉我model和数组的区别,嘻嘻——一不小心小白的本性暴露了,上面呐废话说完了,上一下demo
<td > <!--<span (showTime)="convertToDate({{examInfo.examinationEntity.startingDate}})"></span>--> <li > {{examInfo.examinationEntity.startingDate}} --- {{examInfo.examinationEntity.endingDate}} </li> </td>
this.dataservice.getExamInfoByStudentId(this.url).subscribe( res => { this.examInfoModel = res['data']; this.examInfoModel.forEach(x=>{ x.examinationEntity.endingDate = this.convertToDate(x.examinationEntity.endingDate);//方法调用converToDate() x.examinationEntity.startingDate = this.convertToDate(x.examinationEntity.startingDate); }) console.log(this.examInfoModel); console.log("this.exampaper---"+this.examInfoModel.forEach.prototype) }) } } convertToDate(nows ){ // return new Date(parseInt(date)*1000).toLocaleString().replace(/:d{1,2}$/,'') //return new Date(parseInt(date)*1000).toLocaleString().replace(/年|月/g,"-").replace(/日/g,' ') var now=new Date(nows); var year=now.getFullYear(); var month=now.getMonth()+1; var date=now.getDate(); var hour=now.getHours(); var minute=now.getMinutes(); var second=now.getSeconds(); return year+"年"+month+"月"+date+"日 "+hour+":"+minute+":"+second; }
http://www.cnblogs.com/sure2016/p/5978062.html 记得看评论
原文链接:https://www.f2er.com/angularjs/146076.html