I have the following code that has the <count-characteres>
directive
<label class="control-label"><cr/>Género <count-characters c-name="genero"></count-characters></label>
<div class="input-group">
<input type="text" name="genero" class="form-control" name="genero" equired="" ng-model="produccionGeneroSel.genero" ng-maxlength="{{validations.genero.maxlength}}">
<span class="input-group-addon"><i class="fa fa-font"></i></span>
</div>
What I'm trying to do is that when you start writing in the input
start a counter of remaining characters and when I leave the input
disappear and I can not call the directiva
, passing the maxlength
and know what input
I'm writing. Try with $watch
but I could not walk
app.directive('countCharacters', ['$injector', function ($injector) {
return{
retric:'E',
replace: true,
scope:{
cName: '=name'
},
template: function(){
return '<span>caracteres restantes</span>'; },
link: function($scope, element, $attrs){
}
};
}]);
I'm going to use it for the name
tag input
if there are several in the same form.