$scope.generateUrl = function(text) { return text ? text.replace(/\s+/g, '-').replace(/[^a-zA-Z0-9_-]/g, '') : null; };