I created a directive that adds a line of table when one clicks on the button to add to the level of the directive -- more precisely the button of the last column. I want that when one clicks on this button that a method is in my controller and then call
myapp.directive("newCandidat", function() {
return {
restrict : "E",
template : "<tr>"+
"<td><input class='form-control' value='' disabled='disabled'></td>"+
"<td><input class='form-control' value='' disabled='disabled'></td>"+
"<td><input class='form-control' value=''></td>"+
"<td><button ng-click='method()'>click</button></td>"+
"</tr>",
replace: true,
transclude:true,
terminal: true,
scope:{method:'&'},
link: function(scope, element, attrs) {
console.log(element);
}
};
});
myapp.controller("Controller",function($scope,$compile){
$scope.addCand=function(){
angular.element($("#candList")).append($compile("<new-candidat method='clickMe()'><new-candidat>")($scope));
}
$scope.clickMe=function(){
console.log("Click me");
}
});