I have a problem to activate ng-click in prepend html using angularjs. I found an answer which helps solving almost same problem as mine which is include ng-click in apppended html when loaded as controller (http://next.plnkr.co/edit/5kjo8u7Qiyw6KHFO1jkh?p=preview&preview). the difference is :
I'm trigerring the prepend using a function in my controller so the user will click a button which open a modal. User will see the item list and choose few item within the popup modal.
If user clicked the item the item will be prepend to other html within same page(main page which is not in the pop-up modal) and the selected item will be disabled to prepend.
So far i could do it until this step
But i want to have a feature which enable user to delete the selected item in main page and make the deleted item available in pop-up modal again.
So how could i include/activate my ng-click in my prepend which locate in my function controller. I want to trigger MyFunc2 in my code.
Angular js:
app.controller('myCtrl', ['$scope', function($scope,$compile) {
$scope.myFunc = function(itemName,data1) {
var myEl = angular.element( document.querySelector( '#divID' ) );
var html="<button ng-click='myFunc2()'>"+itemName+"</button>";
myEl.prepend(html);
};
$scope.myFunc2 = function() {
alert("a");
};
});
My html which trigger the angular
<html>
<head>
<link rel="stylesheet" href="lib/style.css">
<script src="lib/script.js"></script>
</head>
<body>
<div ng-app="app" ng-controller="MainCtrl">
<button class="btn btn-success" type="button" ng-click="myFunc('tes',data1)">Choose</button>
<div id="divID" style="margin-left: 25px;">
</div>
</div>
</body>
</html>
Sorry for my bad english. I'm little hard to explain it hope someone could give good explanation(edit).
Update :
This is the problems i face which i build it to plunker for easier understanding the problems : http://next.plnkr.co/edit/RgWNX1zEjJe1BhoZ?open=lib%2Fscript.js&preview
i want to make the prepend button could run function 2 or alert in this program(ng-click prepend button isnt working).