Search code examples
javascriptangularjsangular-filters

custom filter expression for a specific part of a string in angular.js


I want to make a custom filter that only displays the 12th character - 16th character of the string

I made this filters.js file :

angular.module('customFilters', []).filter('specificDate', function() {
  return function(input) {

  };
});

The things i want to put the expression on are all the options from this select item :

<select ng-model="selectedSong" ng-options="song as song.played_at for song in songs.tracks"></select>

Solution

  • In angular you can format date types. In you case you can use like this:

    <p>{{song.playedAt | date:'hh:mm'}}<p/>
    

    AngularJS Date Filter