The Angularjs service returns functional objects when called from a controller?

var newservices = angular.module('newservices', []);
newservices.service('newservice', function ($http) {
newdata: function(parameter){
            return $http.get('/devicedetails/'+parameter).success(function(data)        {
                return data



The above service is included in one of my controllers


while trying to print data what i get is $http function object as shown below

Object {then: function, catch: function, finally: function, success: function, error: function}

why is this so??

What you see is not an error. It's a Promise. You did an $http GET request, which is asynchronous. $http.getreturns a promise that will be resolved when the remote request is completed. In that moment, you'll get the final value.

See this example, where getShops would be your method newData

 this.getShop = function (id, lang) {
    var promise = $http.get(appRoot + 'model/shops_' + lang + '.json');
    return promise;

In a controller you can use it like this:

   Shops.getShop($ (response) {
       console.log("data is",;
       $ =[$];

When the data is ready, assign it to a scope.

In your case:

var data;
newService.newdata($scope.dummy).then(function (response) {
   data =;