I'm currently trying to implement a very simple directive in AngularJS. In the end, I want to be able to use the directive like this:
<share-buttons url="google.com"></share-buttons>
My directive looks like this (coffee script):
module.directive 'shareButtons', () ->
controller = ['$scope', ($scope) ->
$scope.share = () ->
console.log $scope.url
]
return {
restrict: 'EA'
scope: {
url: '=url'
}
templateUrl: viewpath_common('/directives/share-buttons')
controller: controller
}
And here's my template (Jade):
.social-icons
button.btn.btn-li(ng-click="share()")
i.fa.fa-linkedin.fa-fw
When I click the button, the correct function is called ($scope.share), but the only thing logged is undefined.
Can you help me?