Search code examples
htmlangularjshtml-escape-characters

How do I show a string containing escape characters in AngularJS


I have a UNC file path stored in a structure

scope.sites = [
    {
        id: 1,
        nickname: 'Development',
        sitepath: '\\SERVERA.mydomain.com\sites\panoply\wwwroot',
        active: true
    }
];

I want to display the sitepath in the tooltip, as such:

<label style="width:100%;font-size:10px;" title="{{target.sitepath}}">
    {{target.nickname}}
</label>

But as backslashes are escape characters what I get is \SERVERA.mydomain.comsitespanoplywwwroot.

I thought I could use {{target.sitepath.replace('\\', '\\\\')}} or {{target.sitepath.replace('\', '\\')}}.

But neither of those seem to work.


Solution

  • Unfortunately, what you're asking for isn't possible. This would have to be fixed when scope.sites is created since it's currently providing you with malformed JSON.