i have one controller and want to create dymanically element.When i create it the element should call the controller function ,but the function is not called
app.controller('AbnTestController', ['$scope','$timeout',function($scope,$timeout) {
..........................
var tree1;
tree1 = [
{
label: 'test1',
id:'1',
type:'t',
}];
return $scope.addnew= function() {
.........
something
};
In my directive ,i create dynamic element;
app.directive('mytree', [
'$timeout', function($timeout) {
return {
restrict: 'E',
controller: function($scope) {
$scope.launch = function (mn) {........something.....}},
template: "<a ng-click='addnew()'>Click</a>",
replace: true,
scope: {
treeData: '=',
onSelect: '&',
initialSelection: '@',
treeControl: '='
}
...........
}}]);
I want to call 'addnew' function from dynamically created element.