Hello,

"menuRequest" returns a httpPromise not the actual ajax response since xhr 
is processed async. The output you see is string representation of a 
promise.

On Monday, December 15, 2014 at 10:30:44 AM UTC+2, jollu sandeep kumar 
wrote:
>
> created a controller and calling function through ng-click="menu()"
> and the return object is not actual json object 
>
> NOTE:two different angular scripts:::
>
>
> (function(window, angular, undefined) {
>     'use strict';
>     var menu = angular.module("myMenu", ['myApps']);
>     menu.controller('menuController', ['$scope', '$http', 'menuService', 
> 'HelloDude', function(o, $http, menuService, HelloDude) {
>             o.menu = function() {
>                 var data1 = menuService.menuRequest();
>                 console.log("In Menu Controller and JSON object is:    " + 
> JSON.stringify(data1));
>                 o.jsk = HelloDude.user();
>                 console.log("hello world:   " + o.jsk);
>                 return data1;               
>             };
>             console.log("hello world:   " + JSON.stringify(o.menu()));
>         }]);
> })(window, window.angular);
>
>
>
>     angular.module("myApps",[]).service('menuService', function($http) {
>         return {
>             menuRequest: function() {
>                 return $http({
>                     method: 'GET',
>                     url: "/demo/jsonobjects/foodjson.json",
>                     headers: {'Content-Type': 'application/json'},
>                     cache: false
>                 }).success(function(data) {
>                     console.log("output json is " + "      " + data);
>                     return data;
>                 });
>             }
>         };
>     });
>
>
> {"$$state":{"status":0,"pending":[[{"promise":{"$$state":{"status":0}}},null,null,null]]}}
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to