wher should i use the $http in angularjs? in the controller or in the service? i have already implement it in the service, but i want to execute not at the start of the app, i want to execute after some user actions, is this possible in the service?
'use strict';
/* Services */
// Demonstrate how to register services
// In this case it is a simple value service.
angular
    .module('myApp.services')
    .service(
            'RestService',
            function($http, $log) {
                this.getERPProfile = function() {
                    var request = request;
                    request = JSON.stringify(request);
                    $http(
                            {
                                url : url,
                                method : "POST",
                                headers : {
                                    'Accept' : 'text/xml',
                                    'Content-Type' : '"text/xml; charset=\"utf-8\""'
                                },
                                dataType : 'xml',
                                data : request
                            }).success(
                            function(data, status, headers, config) {
                                var v1 = data;
                                return data;
                                $log.log(v1);
                            }).error(
                            function(data, status, headers, config) {
                                var v2 = status;
                                return data;
                                $log.log(v2);
                            });
                };
and has someone a good documentation about the difference of factory and service? the angulajs site does not help me to understand.
thanks for your help!
 
     
    