javascript - AngularJS - Directive formatter is not working for null value -


greeting. in case, can use formatter when ngmodel value (val @ below) not null. (< input > tag formatted.)

ngmodelctrl.$formatters.push(function (val) {     if (val) {         console.log('log positive');         return 'record found';     } else {         console.log('log negative');         return 'no record';     } }); 

that means < input > tag formatted while val contain value. however, found although 'log negative' shown, < input > tag not being formatted well.

may know if there way fix this? in advance.

update 1

here full code of usage

html

<div ng-app="myapp" ng-controller="memberdetailctrl" ng-init="ent.lastdepositdate=null;">     <tit-date title="depositdate" ng-model="ent.lastdepositdate"></tit-date></tit-txt> </div> 

javascript

angular.module("myapp", [])  .controller("memberdetailctrl", function ($scope) {  })  .directive('titdate', function () {     return {         restrict: 'e',         scope: {             title: '@',             fieldname: '@',             ngmodel: '='         },         template: '<div><span>{{title}}: </span><input ng-model="ngmodel" datepicker readonly /></div>'     }; }) .directive('datepicker', function () {     return {         restrict: 'a',         require: 'ngmodel',         link: function (scope, element, attrs, ngmodelctrl) {             ngmodelctrl.$formatters.push(function (val) {                 if (val) {                     console.log('log positive');                     return 'record found';                 } else {                     console.log('log negative');                     return 'no record';                 }             });         }     } }); 

thanks bros, found bug in angularjs 1.3.0. once upgraded current version.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -