javascript - IE 'x' icon is not clearing the counter? -
i have created angular directive counts character inputs , text area, working expected, problem raised user when clear input using ie 'x' icon not clear out count should set maylength
of 256. how can resolve issue ie ?
main.html
<div class="col-md-3"> <input type="text" class="form-control" ng-model="input.searchvalue" placeholder="enter search item" maxlength="256" name={{$index}} data-tooltip-html-unsafe="<div>{{256 - input.searchvalue.length}} characters left</div>" tooltip-trigger="{{{true: 'focus', false: 'never'}[ input.searchvalue.length >= 0 || input.searchvalue.length == null ]}}" tooltip-placement="top" tooltip-class = "bluefill"/> </div>
directive.js
angular.module('mymaxlength', []).directive('mymaxlength', function () { 'use strict'; return { restrict: 'a', require: 'ngmodel', link: function (scope, elem, attrs, ctrl) { attrs.$set('ngtrim', 'false'); var maxlength = parseint(attrs.mymaxlength, 10); ctrl.$parsers.push(function (value) { if (value.length > maxlength) { value = value.substr(0, maxlength); ctrl.$setviewvalue(value); ctrl.$render(); } return value; }); } }; });
Comments
Post a Comment