0

I am receiving a value that I wish to strip of garbage, then pass to Angular's date format feature.

This is what I get:

/Date(1481328000000)/

I'd like ng-repeat to strip everything that's not the number, create a date from it then use:

<td>{{match.delivery_deadline_date | date: 'yyyy-MM-dd'}}</td>

In my ng-repeat directive. Is there anywhere I can specify to run a custom function that would strip the garbage before it tries to format it ?.

I've looked around and anything I googled ends up being about running code once ng-repeat is done, not running custom code on each rendered record.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Francis Ducharme
  • 4,848
  • 6
  • 43
  • 81

1 Answers1

2

You could always pass it a filter function. <td>{{match.delivery_deadline_date | dateFilter}}</td>

Then you would have a date filter function that sorts the date the way you want it.

angular.module('module.name')
  .filter('dateFilter', function () {
    return function (dateInputHere) {
       \\do some manipulation please
    }
  }
});
axhi
  • 126
  • 1
  • 3