I\'m trying to get my head around directives, i can easily use the template function to throw out my HTML, however, if i have an ng-click within my template, how can i acces
Your link function is defined like this:
link: function(scope, elem, attrs) {..}
however you are writing functions on $scope
variable:
$scope.scrollRight = function () {
console.log("scrollRight clicked");
};
$scope.scrollLeft = function () {
console.log("scrollLeft clicked");
};
In this case $scope is not actually injected into link function (and can't be injected), so link is just simple function with parameters. You should change $scope
to scope
and it should work:
scope.scrollRight = function () {
console.log("scrollRight clicked");
};
scope.scrollLeft = function () {
console.log("scrollLeft clicked");
};
Are you sure the link function parameter is named scope
, not $scope
?