Reversible string

by Evgeniy Lukovsky

HTML

<div ng-app="app" ng-controller="testController">
    <ol>
        <li ng-repeat="something in things">{{something | reverse}}</li>
    </ol>
</div>

JavaScript

'use strict';

var app = angular.module('app', []);

app.controller('testController', ['$scope', function ($scope) {
    $scope.things = ['ddkdkdkzzz'];
    $scope.things.push('addd');
}]);

app.filter('reverse', function () {
    return function reverse(input, output) {
        if (!output) output = '';
        if (!input.length) return output;
        return reverse(input.substr(1)) + input[0];
    };
});