How to call function after change input

93 Views Asked by At

Using Angular 1.6

I´m trying to call some function like $scope.myFunction after change inputs

My code look like this

<md-input-container class="col-sm-12 md-block no-left-padding">
                        <label>Name</label>
                        <input name="name" ng-model="name" onfocusout="myFunction()">
</md-input-container>

I´m getting this error when I unfocus the input

Uncaught ReferenceError: myFunction is not defined
    at HTMLInputElement.onfocusout
1

There are 1 best solutions below

0
Petr Averyanov On

onfocusout behaves similar to onclick - it is standard JavaScript callbacks. To call function from scope/controller you need ng-*, probably you will be happy with ng-blur