I am using a function as a filter for an array, but the array is not getting filtered.
Code is below:
<script>
var app = angular.module('myApp',[]);
app.controller('myController', [function(){
var self=this;
self.name = ["mike", "joe", "steve", "maurice", "ron"];
self.toUpper = function(element){
return element.toUpperCase();
}
}]);
</script>
<div ng-controller="myController as ctrl">
<h1>Hello {{ctrl.name|filter:toUpper}}</h1>
</div>
I'm using Angular 1.3.X - pretty much the newest version. Is it no longer possible to filter an array with a function? or Do I need to explicitly create a filter for this?
Aucun commentaire:
Enregistrer un commentaire