'use strict';

app.directive('deleteFromList', function() {
  return {
    restrict: 'A',
    scope: {
      item: '=',
      list: '='
    },
    link: function(scope, element, attrs, ctrl) {
      element.on('click', function(event) {
        var idx = scope.list.indexOf(scope.item);
        scope.$apply(function() {
          
          scope.list.splice(idx, 1);
        });
      });
    }
  };
});