0

With this example: http://jsfiddle.net/lesouthern/y3pXn/ for this filter:

.filter('telanchor',function() {
    return function(s) {
        var rString = '';
        if(typeof s !== 'undefined' && angular.isString(s)) {
            rString = 'tel:+' + s.replace(/\D/g,'');
        }
        return rString;
    }
})

It filters correctly to this string in Angular 1.0.3:

    <a href="tel:+5103381927">Tel Number</a>

In 1.0.7 it generates to:

    <a href="unsafe:tel:+5103381927">Tel Number</a>

How do I not generate this 'unsafe' string?

thank you

koolunix
  • 1,995
  • 16
  • 25

1 Answers1

1

Angular seems to be recognizing your href as unsafe. Try something like this in your configuration block:

angular.module('module').config(['$compileProvider', function ($compileProvider)
{
      $compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
      /* The regular expression will match your "unsafe"
        link format and add it to the whitelist */
}]);

Here's a more detailed explanation: unsafe link in angular

Community
  • 1
  • 1
sushain97
  • 2,752
  • 1
  • 25
  • 36