I have a filter
angular.module('filters', []).filter('check', function(data)
{
return function(name)
{
var a=new Array();
a[0]="hello";
a[1]="hi";
return a;
};
});
As you can see the filter is returning an array. How can i traverse through the content in the template (html page).
{{name|check:data}}
I am calling the filter and it returns the result as : ["hello","hi"]
How can I traverse through the array in the template. Please help.
You can use filters in ng-repeat.
Demo: http://jsfiddle.net/sunnycpp/YbdXQ/7/
<div ng-controller="myCtrl">
<input type="text" ng-model="strInput" >
<ul>
<li ng-repeat="text in strInput|split">
{{text}}
</li>
</ul>
</div>
var angModule = angular.module('myApp', []);
angModule.filter('split',function() {
return function(strData) {
return strData.split(" ");
}
});
angModule.controller("myCtrl", function($scope) {
$scope.strInput = "Provide your input here";
});