Your filter function is just an expression, which angular filter uses to filter out the items in the provided list. If you return a truthy value it will be a part of the resultant list else it wont just be. In your case you are just returning the value converting to uppercase, not really updating the value.
See arguments section :
function(value, index): A predicate function can be used to write arbitrary filters. The function is called for each element of array. The final result is an array of those elements that the predicate returned true for.
All you just need is to use the existing uppercase filter which is supposed to be used with the item not a list.
An example:-
<ul>
<li ng-repeat="nm in ctrl.name">{{nm | uppercase}}</li>
</ul>
However if you are really looking to make your filter expression function work, then you need to modify the value in the array (3rd argument), but this will just change the source array itself. Like here
self.toUpper = function(element, idx, list){
return list[idx] = element.toUpperCase();
}
And remember that view filters run twice atleast every digest cycle, So you should really chose whether a DOM filter is really required or not based on if they are just one time formatting or not. If one time formatting, do it on the controller while setting up the view model itself.
self.name.map(function(name){ return name.toUpperCase(); });
Though it doesn't make much sense to do this (apply filter on the list displayed), you would need to create a filter in-order not to change the source array itself.
app.filter('toUpperList', function(){
return function(itm){
if(!angular.isArray(itm)) return;
return itm.map(function(itm){ return itm.toUpperCase() });
}
});
and
<h1>Hello {{ctrl.name | toUpperList}}</h1>
.toUpperCase()
to do with filtering? O.o – Andreas Jan 1 at 18:00