Last active
November 1, 2016 19:18
-
-
Save davutg/40fa1ac4481a9d1fe27db4816386d45e to your computer and use it in GitHub Desktop.
Escape html tags filter for angular 1.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.filter('escapeHtml', function () { | |
var entityMap = { | |
"&": "&", | |
"<": "<", | |
">": ">", | |
'"': '"', | |
"'": ''', | |
"/": '/' | |
}; | |
return function (str) { | |
return String(str).replace(/[&<>"'\/]/g, function (s) { | |
return entityMap[s]; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment