javascript - Angular - parsing controller variable for binding -
i have controller call service , gets data, rough format of obj.id, obj.email, obj.date etc.... date being returned 2017-08-14t16:52:24.000z after using
var d = new date(); var currenttimedate = d.tolocalestring(); (funnily enough if use code, clean date string, after writing mongoose collection , reading later, it's returned
when using ng-repeat directive iterate through returned list of objects, i'd clean date property. rather doing
obj[index].date = obj[index].date.slice( //returns 2017-08-14 obj[index].date.substr(0,obj[index].date.indexof(t)) , //returns 16:52:24 obj[index].date.substr(obj[index].date.indexof(t+1) , obj[index].date.indexof('.') )
snippet inside controller, there way in html view during ng-repeat procedure whereby write like:
<div> {{obj.date = 'string building done here'}} </div>
you can filter <div> {{obj.date | date:'yyyy-mm-dd'}}</div>
or in controller $filter('date')(obj.date, 'yyyy-mm-dd');
Comments
Post a Comment