Skip to content

Instantly share code, notes, and snippets.

@robbieferrero
Last active December 18, 2015 11:29
Show Gist options
  • Save robbieferrero/5776511 to your computer and use it in GitHub Desktop.
Save robbieferrero/5776511 to your computer and use it in GitHub Desktop.
angular widont filter
filter('widont', function() {
return function(text) {
return text.replace(/([^\s])\s+([^\s]+)\s*$/, "$1 $2")
}
});
<!-- for this filter to work it must be applied using ng-bind-html-unsafe -->
<div ng-bind-html-unsafe="thing.description | widont"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment