简体   繁体   中英

Prevent tooltip in converting HTML Entities

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

The above code for tooltip displays "PROJECT>". But what I need is to display the text as is "PROJECT&GT"

Is there a way to do this? I'm using angular.

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" /> 

you can try something like this: create angular filter :

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

    var charMap= {
        "&": "&amp;",
        "<": "&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}}" />

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" /> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM