Cannot access to $scope and Food inside destroy function.
foodProject.controller('FoodsCtrl', function($scope, Food) {
$scope.foods = Food.index();
$scope.destroy = function(food){
debugger;
console.log(Food, $scope);
food.$destroy();
};
});
The local scope variables are only
food: Resource
this: $get.e.$new.a
I can’t find $scope and Food
http://jsfiddle.net/fW2EA/1/
http://jsfiddle.net/wizztjh/fW2EA/3/
Include this line in your destroy function (it is missing from your fiddle):
Then in your debugger, check the Closure section of Scope Variables (I was using Chrome), when stopped on your break point.
Foodand$scopeare in there (as one would expect!).thisin the context of the destroy function is a new scope within the ng-repeat so is not the same as$scope, although both are scopes.