i have a problem with AngularJS, and it is that i wrote a function inside my controller, and i want to call it inside an event listner, but i get undefinded !!
The Code controller looks like:
inputApp.controller('my_controller', ['$scope', '$upload', '$http', '$filter', '$sce', '$timeout',
function ($scope, $upload, $http, $filter, $sce, $timeout) {
$scope.changeBlock = function (block) {
// DO SOMETHING
};
$scope.$on('$locationChangeStart', function($scope, next, current){
// Calling the following function makes an error
$scope.changeBlock('Block_NAME');
$scope.preventDefault();
});
}]);
so calling that function inside $scope.$on..... make an error:
ERROR:$scope.changeBlock is not a function !!
Could you please help me, how can i call my function inside that listner ?!
Regards Wael