I am dynamicaaly adding Li elements in which i have attached scope function .But when i am clicking on that it gets called multiple times. Please see this fiddle demo where i am getting this issue. http://jsfiddle.net/udmcv/260/
The Html is as below
<div style="border:solid;color:red;Margin-bottom:4px;">
Click on Create Button to Generate the required li'sThe issue is that when there multiple Li the corresponding is getting called multiple time
<ul id="ulTabList" >
</ul>
</div>
<div style="margin-top:10px;">
<input type="button" ng-click="Addli()" value="Create"/>
</div>
and below is the Angular Code that i am using
var app = angular.module('my-app', [], function () {
})
app.controller('AppController', function ($scope, $compile) {
var workGroupTab ="TestA"
$scope.Addli =function(){
var el = $("#ulTabList").append('<li ng-click="OpenWorkGroupTab();">Text of Li</li>'
+'<input id="btnClose_4341" type="button" value="btn" style="margin-left:1px;" ng-click="fn_btnClose()">');
$compile(el.contents())($scope);
}
$scope.fn_btnClose = function(){
console.log('clicked'+ 'val');
}
$scope.OpenWorkGroupTab =function(){
console.log('val2');
}
})
I have also seen some post which says some suggestion but that din't work for me. The issue is like suppose when i have 3 li genrated then on click of first Li button it gets called 3 times. When i am clicking on 2nd Li button it's getting called 2 times and so on.
Please suggest some idea for this problem. Thanks!