For example I have some ng-repeat with default rows without remove button and i want to add new rows that can be removed. Remove function does't work in added row. I know that i can solve this problem by using directive and $compile but i dont understand how to use it with ng-repeat.
HTML
<body ng-app="TestApp" ng-controller="Test">
<ul>
<li ng-repeat="o in array">
<div id="name">{{ o.name }}</div>
<div id="remove" ng-bind-html="o.remove"></div>
</li>
</ul>
<fieldset>
<input ng-model="inputname">
<button ng-click="addRow(inputname)">Add row</button>
</fieldset>
</body>
JS
angular.module('TestApp', []).controller("Test", function($scope, $sce) {
$scope.array = [{name: "Test1"},{name: "Test2"},{name: "Test3"},{name: "Test4"}]
$scope.addRow = function(name){
var a = { name: name,
remove: $sce.trustAsHtml("<button ng-click='removeRow($index)' </button>")
}
$scope.array.push(a)}
$scope.remove = function(index) {
$scope.array.splice(index, 1)}
})
Here is an example http://plnkr.co/edit/0WFmvT?p=preview