I want pass arguments from directive to controller. Into html i have:
<div id="myTest" class="scrollable-content" scrolly="inScroll(value)">
My directive is:
app.directive('scrolly', [function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
console.log('loading directive');
element.bind('scroll', function () {
var value = 1;
alert(attrs.scrolly);
scope.$apply(attrs.scrolly);
});
}
};
}]);
into controller i have:
$scope.inScroll = function(value) {
alert(value);
};
When i scroll the page, the directive set the value = 1; and then call the function inScroll(value), but the function receive value undefined
Can you help me? Thank You
just replace
var value = 1;
with
scope.value = 1;