The following controller works without problem.
app.controller('foo', ['$scope',function ($scope) {
$scope.delete = function(){
bar($scope);
}
}]);
I tried to make it a little cleaner by using bind
:
app.controller('foo', ['$scope',function ($scope) {
$scope.delete = bar.bind(null, $scope);
}]);
Unfortunately, this form does not work as expected and $scope
is always supplied with an old version of $scope in bound method (bar
here), even after $scope has changed to refer to a different value. What is wrong with it?
What else?
If I should not use bind
here, what is the alternative?