I am developing a mobile app using angular2
and ionic 2
,
I have 3 buttons
for call
, sms
and email
as below
<a ion-button href="tel:{{contact.cellphone}}" color="primary">
<ion-icon name="call"></ion-icon>
Call
</a>
<a ion-button href="sms:{{contact.cellphone}}" color="secondary">
<ion-icon name="text"></ion-icon>
SMS
</a>
<a ion-button href="mailto:{{contact.email}}" color="dark">
<ion-icon name="mail"></ion-icon>
Email
</a>
Call
and email
are working fine, but not sms
, it seems angular adds unsafe:
in-front of my expression and it will become like below
<a color="secondary" ion-button="" ng-reflect-color="secondary" class="button button-md button-default button-default-md button-md-secondary" ng-reflect-href="unsafe:sms:+16475374201" href="unsafe:sms:+16475374201"><span class="button-inner">
even I tried this
<a ion-button [attr.href]="'sms:'+contact.cellphone" color="secondary">
<ion-icon name="text"></ion-icon>
SMS
</a>
still same issue,
When I don't use angular binding it's working fine, for example like this
<a ion-button href="sms:+1647654654" color="secondary">
<ion-icon name="text"></ion-icon>
SMS
</a>
Although it's related to angular but also I checked my config.xml
and sms
is allowed there
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
Update
After using @Apuu solution it become like below
<a ion-button [attr.href]="'sms:'+contact.cellphone | safeUrl" color="secondary">
<ion-icon name="text"></ion-icon>
SMS
</a>