I am using gulp
to run and build to run my application. I am getting file contents using $http
service in my index.js
file and then setting value of a variable like
window.variablex = "http://localhost:8080/appname"
.
here is how I am doing it (in index.js
)
(function ()
{
'use strict';
angular
.module('main')
.controller('IndexController', IndexController);
function IndexController($http){
$http.get('conf/conf.json').success(function(data){
window.variable = data.urlValue;
}).error(function(error){
console.log(error);
});
}
});
And I've created a factory to call the rest APIs of my backend application like
(function(){
'use strict';
angular
.module('main')
.factory('testService',['$resource',testService]);
function agentService($resource){
var agents = $resource('../controller/',{id:'@id'},
{
getList:{
method:'GET',
url:window.variable+"/controller/index/",
isArray:false
}
});
Now, I except a rest call to made like
http://localhost:8080/appname/controller
But it always sends a call like http://undefined/appname/controller
which is not correct.
I can get the new set value anywhere else, but this value is not being set in resource service
objects somehow.
I am definitely missing something.
Any help would be much appreciated