D
D
DimaPolishuk2016-08-30 10:16:36
css
DimaPolishuk, 2016-08-30 10:16:36

How to remove escaping with angular?

have this code

<p ng-bind-html="activeProperty.details | trusted"></p>

activeProperty.details is the given text
A GREAT LOT, THIS IS THE ONE YOU\'VE BEEN LOOKING FOR

trusted - this filter
'use strict';

app
    .filter('trusted', ['$sce', function ($sce) {
        return function (text) {
            return $sce.trustAsHtml(text);
        };
    }]);

how to remove in text, in a word
YOU\'VE
slash?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Aleksandr, 2016-06-21
@MaXComp

Prescribe forul.sub-menu {background: #fff;}

A
Alexey Nemiro, 2016-08-30
@DimaPolishuk

Search and replace?
You can make a separate filter for this :-) I
sketched an example , I have a slash and it doesn’t display like that:

<div ng-app="app">
  <div ng-controller="ExampleController">
    <p ng-bind-html="text | trusted"></p>
  </div>
</div>

angular.module('app', []).controller('ExampleController', function($scope) {
  $scope.text = "A GREAT LOT, THIS IS THE ONE YOU\'VE BEEN LOOKING FOR";
}).filter('trusted', ['$sce', function ($sce) {
  return function (text) {
    return $sce.trustAsHtml(text); // $sce.trustAsHtml(text.replace(/\\/g, ''));
  };
}]);

_
_ _, 2016-08-30
@AMar4enko

Probably, when writing to the database, an escape is made to prevent sql injection? If yes, then perform the reverse operation before serving the content

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question