Sorry for late response. If you want some functionality to run only once (on application load time) and it depends on some functionality in controller then you'll need to put that functionality in a service/factory and you'll inject that service in the run block (associated to that service) which will be executed just after the service is loaded. If you won't inject service in run block then run block will be executed first independent of your service. So this is what will serve your purpose:
angular.module('myangularapp')
.factory('myLogger', ['$http', 'apiUrl',
function ($http, apiUrl) {
'use strict';
function PostService() {
$http({
url: apiUrl + 'TestEndPoint',
dataType: 'json',
method: 'post',
data: //some object
}).then(function success(response) {
}, function errorCallback(errorThrown) {
});
}
return {
PostService: PostService
}
}])
.run(function (myLogger, $rootScope) {
myLogger.PostService();
});