Ler Den2016-10-27 01:34:48
Ler Den, 2016-10-27 01:34:48

AngularJS 1.5.8 how to check posts for html tags?

There is a chat.

<form name="publish">
                    <textarea ng-textarea-enter="msgSend()" name="message" ng-model="textMsg"></textarea>
                   <input class="send-btn" ng-click="msgSend()" type="submit" value="" ng-disabled="isError()">

The message coming in and the text field needs to be checked for html tags so that the SS message doesn't show 'SS' in italics. I think the idea is clear. I found the $sce built-in service, it has a bunch of methods, but not all of them work as I expected. for example
$scope.msgSend = function() {
            var tmp = $sce.trustAsHtml('My name is <div style = "color:red; width: 500px; height: 500px; background: red;"><b>Mudassar Khan</b></div>');            

It will output an empty object, although in theory it should display all the tags as text. What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_ _, 2016-10-27


Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question