No idea how the scope is working internally, but have you

a) logged the result (not only the $scope.result) - just in case? ;)
b) tried to give result instead of $scope.sampleResult as parameter to the 
service? If $scope needs some processing after changes it would have to do 
that AFTER your method
c) if b is the case and you don't want to use the result directly, try a 
setTimeout with 0 as duration

just some guesses from a noob :)

Am Donnerstag, 8. Januar 2015 05:47:28 UTC+1 schrieb Sasikumar Veeraiah:
>
> Hi all,
>
> I'm setting ajax result into a service. while try to retrieve those 
> results getting undefined.
>
> Eg:
>
> $http({
>         url: '/app/demo/sample?a=getSamplesBySearchText',
>         method: 'GET',
>         params: {
>          "searchText" : searchText
>         }
>       }).then(function (result) { 
>
>        $scope.sampleResult=result;
>        
> *resultService.setResult($scope.sampleResult);*      ****Some codes*****
>       
>         $scope.result= *resultService.getResult();*
>
>        console.log($scope.result); -----> *undefined*
>       });
>
>
> *inside resultService*:
>
> var resultObject={};
>
> this.
> *setResult=function(value){*
> resultObject=value;
>
> if i print the "*resultObject*" - i'm getting the ans
> };
>
>
> this.
> *getResult=function(){*   return resultObject;
> }
>
> Some one could explain why i'm not able to get those result's?
>
> *Thanks & Regards,*
> *Sasikumar.V*
>  

-- 
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