I am facing an issue with passing a URL from a controller to a factory in my service. I have multiple URLs and want to dynamically pass any URL.
var youtubeURL = 'https://www.googleapis.com/youtube/v3/videos?part=snippet';
ConnectivityService.check({myurl: youtubeURL}, function(responseSCon) {
And here is the code snippet in the factory:
return $resource(
':myurl',
null,
{
'check': {method: 'GET', params: {myurl: '@myurl'}, isArray: false, cache: false, headers: {'Accept': 'application/json'}}
}
);
The problem arises when the called URL gets encoded as
https://%2F%2Fwww.googleapis.com%2Fyoutube%2Fv3%2Fvideos%3Fpart%3Dsnippet/
I have tried using $sce, encode/decode URI, but nothing seems to work. Can anyone guide me on how to correctly pass a URL?