I have some text like this:
<span>My text</span>   I want to display without tags:
My text   I also don't want to apply the tags, I want to strip them. What's an easy way to do that?
Angular html:
<div>{{myText | htmlToPlaintext}}</div> 
                AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.
Each Angular template in your application is a section of HTML to include as a part of the page that the browser displays. An Angular HTML template renders a view, or user interface, in the browser, just like regular HTML, but with a lot more functionality.
jQuery is about 40 times SLOWER, please do not use jQuery for that simple task.
function htmlToPlaintext(text) {   return text ? String(text).replace(/<[^>]+>/gm, '') : ''; }   usage :
var plain_text = htmlToPlaintext( your_html );   angular.module('myApp.filters', []).   filter('htmlToPlaintext', function() {     return function(text) {       return  text ? String(text).replace(/<[^>]+>/gm, '') : '';     };   } );   use :
<div>{{myText | htmlToPlaintext}}</div>   
                        from https://docs.angularjs.org/api/ng/function/angular.element
angular.element
wraps a raw DOM element or HTML string as a jQuery element (If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite.")
So you simply could do:
angular.module('myApp.filters', []).   filter('htmlToPlaintext', function() {     return function(text) {       return angular.element(text).text();     }   } );   Usage:
<div>{{myText | htmlToPlaintext}}</div> 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With