I have a query regarding an input that is using a link directive. Specifically, I am wondering if it's feasible to identify when the input loses focus within the link function of the directive.
Below is the directive in question:
appDrct.directive('formattedDate', ['$filter', 'formatter', function ($filter, formatter) {
return {
link: function (scope, element, attrs, ctrl) {
ctrl.$parsers.unshift(function (viewValue) {
var val = element.val();
if(!val)
return viewValue;
var dateStr = $filter('date')(val,'dd.MM.yyyy');
if(dateStr == undefined)
return viewValue;
var parsed = viewValue;
if(**BLURRED**){
do something....
}
try
{
var dateParts = dateStr.split('.');
parsed = new Date(dateParts[2],dateParts[1]-1,dateParts[0]);
}
catch(e){
}
return parsed;
});
},
restrict: 'A',
require: 'ngModel'
};
}]);
JADE:
input.form-control(formatted-date='mybirth', name='birth' ,placeholder='jj.mm.aaaa', type="text", datepicker-popup="dd.MM.yyyy", ng-model="mybirth", is-open="$parent.opened[]", close-text="Close")
Plunker showcasing an example: