3

I'm trying to figure how I can open the SMS app using ng-href. When i use

href="sms:?body=text"

it opens up the SMS app on my mobile device. But if I use

ng-href="sms:?body=text"

It doesn't open the SMS app on my device. I tried hovering on the hyperlink with my mouse and it shows me an text/message "unsafe:sms?body" You can see the image below for reference

enter image description here

clestcruz
  • 1,081
  • 3
  • 31
  • 75
  • There is a whitelist function that allows you to identify protocols that are allowed. see here: http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page – Glenn Ferrie Jan 06 '17 at 02:30
  • Hello thank you for the hint. I'm still in the learning phase of angular I can't seem to understand how I can implement it on my problem. – clestcruz Jan 06 '17 at 02:35
  • @clestcruz, can you supply some of the rest of your angular code, particularly where you're instantiating the app, and we can help you to whitelist the sms protocol – haxxxton Jan 06 '17 at 02:51
  • Still need to find it atm, the project was turned over to me so I have to browse through the code. I have little to no idea how I can supply you with the rest of the information – clestcruz Jan 06 '17 at 03:22

1 Answers1

3

If you have a reference to the ng-app object, which can typical be found near the beginning of the angular app code.

you can use this code:

yourapp.config( ['$compileProvider', function( $compileProvider ) {   
    $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|sms|chrome-extension):/);
    }
]);

Hope this helps!

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
  • Thank you for this, I have checked the code there isn't any ng-app embedded to the body tag – clestcruz Jan 06 '17 at 05:19
  • It doesn't need to be on the ‘body‘ tag. But that ng-app identifies the HTML element that contains your app. Could be a div. – Glenn Ferrie Jan 06 '17 at 12:57