Search code examples
cordovaionic-frameworkionic2unsafe

ionic 2 : Getting unsafe url error


I'm trying to open a whats'app link and I'm getting thus error :

WARNING: sanitizing unsafe URL value SafeValue must use
(see http://g.co/ng/security#xss)

here is my code :

<a href="{{surl}}">
<img src="assets/imgs/whatsapp.png" height=35px/></a>

and in the ts file here is what surl holds :

this.url = 'whatsapp://send?text=Hello World!&phone=+966'+this.phone
this.surl = this.dom.bypassSecurityTrustUrl(this.url);

the problem as you can tell is that I'm passing a variable to the url , but cordova won't trust it ! any ideas how can I solve this problem ?


Solution

  • I solved it by <a [href]="surl"></a> where surl is the safe url , and it worked !