angularjs to output plain text instead of html
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 );
With angular.js :
angular.module('myApp.filters', []).
filter('htmlToPlaintext', function() {
return function(text) {
return text ? String(text).replace(/<[^>]+>/gm, '') : '';
};
}
);
use :
<div>{{myText | htmlToPlaintext}}</div>
How to display HTML from model as HTML, not plain text
<p class="text-muted" ng-bind-html="todo.description"></p>
https://docs.angularjs.org/api/ng/directive/ngBindHtml
angularjs to output html clickable element instead of html as a string
I have updated JS Fidle
HTML:
Added
ng-bind-html
<div ng-app="miniapp">
<div ng-controller="Ctrl">
<h1 ng-bind-html="test | parseUrl">{{test}}</h1>
</div>
</div>
Documentation ngBindHtml
How to render text into HTML in AngularJS
You need to inject $sce
service into your controller
or Directive
etc. and use $sce service
like this:-
$scope.Message = $sce.trustAsHtml("<b><i>result has been saved successfully.</i></b>");
And bind this in your HTML page e.g;
<p ng-bind-html = "Message"></p>
How to render raw html with AngularJS?
You need to add ng-bind-html="data.text"
to your h1 tag.
Your html would look like:
<h1 ng-bind-html="data.text"></h1>
Documentation: ngBindHtml
How to remove html tags from text in angular 2
You just need to bind html:
<div *ngFor="let daily of tagesnews">
<span style="font-size: 13px" [innerHTML]="daily.text"></span>
</div>
Related Topics
Xmlhttprequest Cannot Load Xxx No 'Access-Control-Allow-Origin' Header
Ways to Circumvent the Same-Origin Policy
"Thinking in Angularjs" If I Have a Jquery Background
How to Randomize (Shuffle) a JavaScript Array
How to Upload Files Asynchronously With Jquery
How to Clear the Content of a Div Using JavaScript
Adding Additional Data to Select Options Using Jquery
How to Prevent JavaScript Injection Attacks Within User-Generated Html
Open Popup and Refresh Parent Page on Close Popup
Dynamically Loading CSS Stylesheet Doesn't Work on Ie
What Are the Rules For JavaScript'S Automatic Semicolon Insertion (Asi)
Why Is Using the JavaScript Eval Function a Bad Idea
How to Merge Properties of Two JavaScript Objects Dynamically
JavaScript Infamous Loop Issue
How to Detect a Click Outside an Element