On Wednesday, 8 October 2014 21:46:00 UTC-4, [email protected] wrote:
>
> I'm new to AngularJS, so I'm sure I'm doing something wrong. ;-)
>
> I have this service:
>
> angular.module('TestApp')
>
>     .factory('faqlistService',[function(){
>         request = new XMLHttpRequest();
>             request.open('GET', '
> http://www.humber.ca/elearning/BB9/sfq/js/faqlist.json', true);
>
>             request.onload = function() {
>                 if (request.status >= 200 && request.status < 400){
>                     resp = request.responseText;
>                     console.log(resp);
>                     return resp;
>                 } else {
>                     // We reached our target server, but it returned an 
> error
>                     console.log("error");
>                 }
>             };
>
>             request.onerror = function() {
>             // There was a connection error of some sort
>                 console.log('connection error');
>             };
>
>             request.send();
>     }]);  // faqlistService {ends}
>
> it is used by this controller:
>
>     .controller('NextCtrl',['$scope','$location','faqlistService', 
> function($scope,$location,faqlistService){
>         $scope.isVisible = true;
>         $scope.next      = "Next";
>         $scope.loc       = $location.url();
>         console.log('Ask faqlist');
>         $scope.list = faqlistService;
>         console.warn($scope.list)
>     }])
>
>
> The result is that $scopellist is undefined but I would expect to have my 
> json result. What am I doing wrong?
> BTW. I used $http too and I get the same result.
>
> Any help would be appreciated.
>
> R
>


Justin,

I figured the problem. Thanks for posting.

Best,

R. 

> .
>

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