Skip to content Skip to sidebar Skip to footer

Prevent Tooltip In Converting HTML Entities

The above code for tooltip displays 'PROJECT>'. But what I need is to display the text as is 'PROJECT>' Is there a way to do this? I'm using angular.

Solution 1:

you can try something like this: create angular filter :

angular.module('ppvApp.event').filter('escapeHtml', function() {

    var charMap= {
        "&": "&",
        "<": "&lt;",
        ">": "&gt;",
        '"': '&quot;',
        "'": '&#39;',
        "/": '&#x2F;'
    };

    return function(str) {
        return String(str).replace(/[&<>"'\/]/g, function(s) {
            return charMap[s];
        });
    }
});

and then use it as:

 <input ng-model="test" placeholder="pre" type="text" title="{{'PROJECT&GT' | escapeHtml}}" />

Solution 2:

You need to use the encoded string in the title. You can use online tools such as this one to do this.

<input ng-model="test" placeholder="pre" type="text" title="PROJECT&amp;GT" />

Solution 3:

One way to go is to separate the & from the GT (or any other similar entity) with a &#xfeff; which is a Zero Width No-Break Space (http://www.codetable.net/hex/feff), like this:

<input ng-model="test" placeholder="pre" type="text" title="PROJECT&&#xfeff;GT" />

Post a Comment for "Prevent Tooltip In Converting HTML Entities"