Angularjs Ng-repeat With Filter And Track By $index Not Working
That is because you are using the filter expression wrongly. You are using it as expression for angular built-in filterFilter
. Instead you want to use your filter as is, because using it as expression you would need to modify the original array (3rd argument in the filter expression function).
Instead change:
ng-repeat="video in videosJSON.videos.name | filter:videoUrl
to
ng-repeat="video in videosJSON.videos.name | videoUrl
Do:-
<video ng-repeat="video in videosJSON.videos.name | videoUrl track by $index" preload="metadata" ng-src="{{video}}" type="video/webm">
</video>
and your filter evaluator should be
var videoUrl=function(names){
if(!angular.isArray(names)){ return []; }
return names.map(function(name){
return "./videos/"+name;
});
894