I have a directive like so:
<div ng-repeat="(key, value) in $parent.item.detailedPlan track by $index">
<ul contenteditable="true" class="plan-actions" data-placeholder="Add Plan ...">
<li ng-repeat="planItem in value" ng-show="(key+1)==$parent.dayItem.value">
{{planItem}}
</li>
</ul>
</div>
and a directive function like so:
.directive('planText', function(){
return {
restrict:'E',
templateUrl: 'app/partials/planText.html',
link: function(scope, element, attrs){
element.find("ul").bind('keydown', function(event){
console.log("keydown event");
if (event.keyCode == 8) {
// console.log("backspace pressed");
if ($(this).children().length == 1 && $(this).children("li").text().split("").length == 0) {
console.log("stop li removal");
event.preventDefault();
}
}
});
element.find("ul").bind('focus', function(event){
if ($(this).children().length ==0 ) {
console.log("insert li");
$(this).append("<li></li>");
}
});
}
}
})
the data structure it reads from, is an array of arrays. However neither of the event listener functions fires . Adding a $compile does not help either. Please help !