1

Is there anyway to pass a string through ng-href and achieve the same result as if it was the value of that directive?

e.g. {{ url | ng-href }}

So that way the filter or pipe sanitizes any values and conforms the proper url scheme.

shershen
  • 9,875
  • 11
  • 39
  • 60
chrisjlee
  • 21,691
  • 27
  • 82
  • 112

1 Answers1

0

Not quite clear what you're trying to achieve. But if you wanted to be able to convert a string in the model into the href attribute on a <a> tag - you may use smth like this $sce.trustAsUrl (angular site docs)

SCE assists in writing code in a way that (a) is secure by default and (b) makes auditing for security vulnerabilities such as XSS, clickjacking, etc. a lot easier.

shershen
  • 9,875
  • 11
  • 39
  • 60