I am trying to do something this this. Using a directive.The idea I have is to bind the event with focus and blur. But the problem with blur is that it changes the icon just after the input is blured.
I want the check item to persist even after blur.If it has the data.
html
<div>
<span class="delete-tag"><i class="fa fa-tags"></i></span>
<input type="text" placeholder="enter label name" class="label-input" my-change>
<span class="span-right"><i class="fa fa-pencil"></i></span></div>
<div>
<span class="delete-tag"><i class="fa fa-tags"></i></span>
<input type="text" placeholder="enter label name" class="label-input" my-change>
<span class="span-right"><i class="fa fa-pencil"></i></span>
</div>
javascript
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
});
app.directive('myChange', function() {
return function(scope, element) {
element.bind('focus', function() {
console.log(element);
element[0].previousElementSibling.firstChild.className = 'fa fa-trash';
element[0].nextElementSibling.firstChild.className = 'fa fa-check';
});
element.bind('blur', function() {
element[0].previousElementSibling.firstChild.className = 'fa fa-tags';
element[0].nextElementSibling.firstChild.className = 'fa fa-pencil';
});
};
});
