My purpose is to consume a REST web service in AngularJS and I am making some trials right now. Below code is not working and throwing following exception. Can you help me identifty the 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 at getUsersFromLocal.
The service is accessible and I tested it through some REST clients.
getUsersFromLocal()
a controller? – Martin Shishkov Apr 26 '15 at 9:10getUsersFromLocal()
defined? The ultimate problem is that Angular's$injector
service doesn't know to do dependency injection on the call togetUsersFromLocal()
(wherever that is in your code). Follow either @zegoline's answer or @pankajparkar's answer to address your problem. – Brian Clapper Apr 26 '15 at 16:17