Hi there I have this "confirmable" button directive which I am working on,
The html code that will trigger the directive 'confirmable'
<span confirmable ng-click='users.splice($index,1)'></span>
the directive: (coffeescript)
angular.module('buttons',[])
.directive 'confirmable', () ->
template: """
<button class='btn btn-mini btn-danger'>
Destroy
</button>
"""
replace: yes
So the end result I'd like to see generated with this directive is
<button class='btn btn-mini btn-danger' ng-click='users.splice($index,1)'>
Destroy
</button>
So far I got it to work with a linking function inside the directive
angular.module('buttons',[])
.directive 'confirmable', () ->
template: """
<button class='btn btn-mini btn-danger'>
Destroy
</button>
"""
replace: yes
link: (scope, el, attrs) -> <---------- linking function
$(el).attr 'ng-click', attrs.ngClick
But I've gone through the directive documentation again, and found the scope property with the =, @, & operators but I am really unsure if they are what I need. Then there's this transclude properties which I still need to understand but at the moment doesn't seem to be helpful either. So while my linking function does the trick for now, but I thought I should ask to see if angular provides a more elegant solution.
Thanks!