UNPKG

angular-filter

Version:

Bunch of useful filters for angularJS(with no external dependencies!)

20 lines (17 loc) 417 B
/** * @ngdoc filter * @name slugify * @kind function * * @description * remove spaces from string, replace with "-" or given argument */ angular.module('a8m.slugify', []) .filter('slugify',[ function () { return function (input, sub) { var replace = (isUndefined(sub)) ? '-' : sub; return isString(input) ? input.toLowerCase().replace(/\s+/g, replace) : input; } }]);