You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.
I'm using a directive for an input text control where i have the following two methods inside controller function.
The first time i paste some text in the text box both methods are triggered. When i type in or delete a character from the text box first is called the validation method and then the ng-change associated method (tiggeredOnTextInputChange) but the value passed (val) is undefined (ng-model="theBindingModelValue"). How can i deal with this?
$scope.tiggeredOnTextInputChange = function (val) {
var processedVal = val.length - 1; //"val" will be undefined the second time ngChange is triggered so this line will throw error
$scope.theBindingModelValue = processedVal;
};
$scope.validateUserInput = function(value){
var isValid = someFactoryWithoutAsyncCalls.validate(value);
return isValid;
}
function testInput() {
function testInputCtrl($scope, someFactoryWithoutAsyncCalls) {
$scope.tiggeredOnTextInputChange = function (val) {
var processedVal = val.length - 1; //"val" will be undefined the second time ngChange is triggered so this line will throw error
$scope.theBindingModelValue = processedVal;
};
$scope.validateUserInput = function(value){
var isValid = someFactoryWithoutAsyncCalls.validate(value);
return isValid;
}
}
testInputCtrl.$inject = ["$scope", "someFactoryWithoutAsyncCalls"];
return {
scope: {
inputName: "@",
inputPlaceholder: "@"
},
restrict: "EA",
require: "ngModel",
replace: true,
templateUrl: "testInput.html",
controller: testInputCtrl
};
}
I'm using a directive for an input text control where i have the following two methods inside controller function.
The first time i paste some text in the text box both methods are triggered. When i type in or delete a character from the text box first is called the validation method and then the ng-change associated method (tiggeredOnTextInputChange) but the value passed (val) is undefined (ng-model="theBindingModelValue"). How can i deal with this?
Html of the directive (testInput.html)
The complete directive:
I call it this way:
The text was updated successfully, but these errors were encountered: