title: success and error function in the controller for a service
body: <p>I have the following code in a service and I am calling fetchData function from the controller.</p>
  
  <p><strong>Service</strong> </p>
  
  <pre><code>app.service("geturl", function($http) {
      urllist = [];
      geturl.fetchData = function() {
          var data = [];
          for (i = 0; i &lt; urllist.length; i++) {
            (function(index) {
              return $http.get(geturl.urllist[index], {
                timeout: 8000
              })
              .then(function(response) {
                data[index] = response.data;
              });
            }(i);
            return data;
          });
      };
  });
  </code></pre>
  
  <p>I want to write the success and error function of $http.get in the controller since it is needed in the UI, how can I go about it?</p>