I've made a directive which uses element.html() to set the html. Inside that html-code I want to be able to call functions in the scope which the directive is used in. Something like this:
app.directive('myDirective', ['$rootScope', function ($rootScope) {
return {
restrict: 'A',
link: function(scope, element) {
element.html('<button ng-click="doit()">Does not work</button>');
}
};
}]);
The doit() function is never called though.
I made a plnkr to demonstrate it: