i am getting a JSON file from local host, i successfully get the data, i can see it when i console log, but when i inject the Factory in my controller it returns a null object, that means the variable erroMessages does not get the JSON object because the success function is not being executed before return in the Factory,please help.
assetInModule.factory('helperFactory',function($http,$sce){
'use strict';
var title = "default";
var errorMessages = {content:null};
return {
title : function(){ return title;},
setTitle : function(newNitle){title = newNitle;},
getErrorMessages : function(){
$http.get('http://127.0.0.1/assetinspa/public/js/helpers/error_messages.json')
.success(function(data){
errorMessages = data;
});
return errorMessages;
}
};
});