I'm experiencing some issues with the ng-show method. I have set it up like this:
Even though the username string length is checked, the ng-show method doesn't seem to hide/show the extra text until after another keystroke. How can I make it update the visibility of the username helper text on key up?
If you take a look at the JSFiddle http://jsfiddle.net/FkAkg/8/
accountApp.directive("stripCharacters", ['$filter', '$http', function($filter, $http) {
return {
restrict: 'C',
link: function(scope, element) {
element.bind("keyup", function() {
if(scope.account.username !== undefined) {
element.val($filter('stripCharacters')(scope.account.username));
if(scope.account.username.length > 2) {
scope.toggleShowUsername(true);
scope.usernameMessage = scope.account.usernameAvailable;
} else {
scope.toggleShowUsername(false);
}
}
});
}
}
}]);
I managed to get it working by using jQuery hide/show on the same element, but I'd prefer to have it functioning in Angular only.
Cheers