I am working on an Ionic project and I have written my service. But in my console.log I get the message saying that I dont have "Access-Control-Allow-Origin " in my header.
How to incorporate this in my service?
Here is my service code:
angular.module('Chemicar.services', [])
.service('ChemicarService', function($http, $q){
var url_youtube = "XXXXXXXXXXXXXXXXXXXX";
var self = {
'youtubeVideos' : [],
'loadYoutubeVideos' : function(){
var d = $q.defer();
$http.get(url_youtube)
.success(function(data){
console.log(data);
self.youtubeVideos = data;
//create an array to hold the prommisses
var promisses = [];
$q.all(promisses).finally(function(){
d.resolve('The promise has been fulfilled');
//console.log("ˆˆˆˆˆ" , promisses);
});
})
.error(function(msg){
console.error("There was an error in retrieving the json data " , msg);
d.reject("The promise was not fulfilled");
});
return d.promise;
}
};
return self;
});
My controller code:
angular.module('Chemicar.controllers', ['Chemicar.services'])
.controller('VideoCtrl', function($scope, $http, ChemicarService){
$scope.youtubeVideos = [];
ChemicarService.loadYoutubeVideos().then(function success (data){
$scope.youtubeVideos = ChemicarService.youtubeVideos;
})
})