I am new to angular and I am trying to list my data in database .However I am gettin $scope not defined error..This is my code
productsService
.getProducts()
.success(function (data, status, headers, config) {
$scope.products = data;
console.log($scope.products);
})
.error(function (error) {
//Showing error message
$scope.status = 'Unable to retrieve product' + error.message;
});
In my product Service I have
return {
getProducts: function () {
return $http({
method: 'GET',
url: '/api/Products'
}).success(function (data) {
alert("success");
// console.log(data);
}).error(function (error) {
//Showing error message
alert("failed");
$scope.status = 'Unable to retrieve products' + error.message;
console.log($scope.status);
});
},
I am just getting failed alert. Please help!!!In backend I am able to get the data from database.