javascript - Angularjs $http.get does not work -


my purpose consume rest web service in angularjs , making trials right now. below code not working , throwing following exception. can me identifty problem?

thanks in advance.

function getusersfromlocal($scope,$http) {  $http.get('http://localhost:8080/people').  success(function(data) {  $scope.data = data;  }); return data; } 

error is: typeerror: cannot read property 'get' of undefined @ getusersfromlocal.

the service accessible , tested through rest clients.

if understood correctly getusersfromlocal function inside controller, function parameters killing $scope, $http object existence, need remove them parameter & removed return statement outside $http won't work in anyways.

code

app.controller('mainctrl', function() {     $scope.getusersfromlocal = function() {         $http.get('http://localhost:8080/people').         success(function(data) {             $scope.data = data;         });     };      $scope.getusersfromlocal(); //call ajax method }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -