Angular filter for applying simple html formatting to text.
Formatting applied:
- Appending linebreak (<br>) after newline(\n).
- Converts urls to link tags
- Escapes html tags
app.controller('showPostCtrl', function($scope){
$scope.text = "example:\n line 1\n line 2\n line 3\n http://example.com"
});
<p ng-bind-html='text|simpleFormat'>
angular.js
angular-sanitize.js
Include lib/angular_simple_format.js into your page and then list simpleFormat
as your module dependency.
window.app = angular.module('YourApp', ['simpleFormat'])
Install bower developer dependencies - bower install
.
Just open - test/runner.html
.
Every fresh idea and contribution will be highly appreciated.
MIT License.