0

I have written custom price format directive using angularjs.

It will trigger an event while 'blur' event happened. But, how do i call the function while opening(by default) the page.. I need to call directive function while opening the page.

<input name="amt" type="text" class="form-control text-right" name="amt" id="amt" data-ng-model="rowUnderEdit.amount" format-currency required>

my directive:

.directive('formatCurrency', function() {
       return { 
              require: 'ngModel',
              link: function($scope, $element, $attrs, ngModelCtrl) {
                     var listener = function(){
                         console.log('>>>>>>>>');
                         ---------------
                         --------------

                         $element.val(currency);
                        }
                     }
                     $element.bind('blur', listener);                     
              }
       }
});

1 Answer 1

1

Simply call the function...

    ....
    $element.bind('blur', listener);                     

    listener();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.