If your role is within the scope of your controller, you can do it simply by using ng-blur
:
<input type="text" ng-blur="getCep()">
If not, do with onBlur
same:
<input type="text" onblur="getCep()">
Example
function controller($scope){
$scope.getCep = function(){
$scope.demo = $scope.cep;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-appng-controller="controller" >
<input type="text"
ng-model="cep"
ng-blur="getCep()"
ng-focus="demo = ''"
><br>
{{demo}}
</div>
In the example above, I just simulated the getCep()
function by making it show what was typed when giving a blur in the text box. Likewise I used ng-focus
to make var demo
empty.