I created a new directive to delete a when the user press the delt keyboard but it is not working.I used the angularjs directive: ng-keypress
the directive: keyboard.js
yemp.planner.app .directive('onKeyEnter', ['$parse', function($parse) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('keydown keypress', function(event) {
if (event.which === 46) {
var attrValue = $parse(attrs.onKeyEnter);
(typeof attrValue === 'function') ? attrValue(scope) : angular.noop();
event.deleteTimelineItem();
console.log("delete");
}
});
scope.$on('$destroy', function() {
element.unbind('keydown keypress')
})
}
};
}]);
<div class="time-lime-item-details" onKeyEnter >
<!-- when the user press delete this div should be deleted -->
</di>
and I add the script line to the html file:
<script type="text/javascript" src="scripts/directives/keyboard.js"></script>