Reputation: 645
I have directive with input
<input ng-model="inputModel" ng-disabled="ngDisabled || isLoading" value="{{value}}" type="{{type}}" placeholder="{{placeholder | translate}}">
I use this directive like this:
<input-ext type="'text'" name="email" ng-model="registerCtrl.email" ng-blur="registerCtrl.test()" required></input-ext>
I want to after blur inside my directive to executed blur in input-ext ... , for this example code in controller, how to make this ?
Upvotes: 4
Views: 14423
Reputation: 645
.directive('inputExt', function() {
return {
restrict: 'E',
templateUrl: 'templates/inputExt3.html',
require: 'ngModel',
scope: {
'name' : '@',
'type' : '=',
'placeholder' : '=',
'value' : '=',
'ngDisabled': '=',
'isLoading' : '=',
'customStatus': '=',
'cutomStatusType': '=',
'test' : '&'
},
link: function($scope, element, attrs, ngModelCtrl) {
$scope.placeholder = $scope.placeholder == undefined ? $scope.name : $scope.placeholder;
$scope.$watch('inputModel', function() {
ngModelCtrl.$setViewValue($scope.inputModel);
});
ngModelCtrl.$parsers.push(function(viewValue) {
ngModelCtrl.$validate();
$scope.invalid = ngModelCtrl.$invalid;
$scope.error = ngModelCtrl.$error;
return viewValue;
});
}
}
})
I dont known that You undestand me well, if user add to inputExt ng-blur and add to this atribiute some argument, function, this function should be executed when user go out from input in directive
Upvotes: 0
Reputation: 451
On your link function you bind them
link: function (scope, element, attrs) {
element.bind('blur', function (e) {
//do something
});
}
Upvotes: 17