Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div some-directive>
<span ng-repeat="item in items">
{{item}} - index {{$index}}
<input type="button" value="x" ng-click="remove($index)"/><br />
</span>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.directive('someDirective', function() {
return {
link: function($scope) {
$scope.items = ["john", "jay", "mary"];
$scope.remove = function(index) {
$scope.items.splice(index, 1);
}
}
}
});