I am getting "ReferenceError: success is not defined" when doing a Restful call from controller to my node.js back end as follows:
authControllers.js:
authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService',
function authCtrl($scope, $location, $window, UserService, AuthenticationService) {
$scope.me = function() {
UserService.me(function(res) {
$scope.myDetails = res;
}, function() {
console.log('Failed to fetch details');
$rootScope.error = 'Failed to fetch details';
})
};
}]);
html:
<div class="row" data-ng-controller="authCtrl" data-ng-init="me()">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Your Details</strong>
</div>
<div class="panel-body">
<p>{{myDetails.data.username}}</p>
<p>{{myDetails.data.email}}</p>
</div>
</div>
</div>
</div>
authServices.js:
authServices.factory('UserService',['$http', function($http) {
return {
me:function() {
return $http.get(options.api.base_url + '/me').success(success).error(error)
}
}
}]);
A successful nodeJs call is being received and it's returning data as well, but couldn't get it in the front end. Please help !