function getDecimals(n) {
  n = n + '';
  var i = n.indexOf('.');
  return (i == -1) ? 0 : n.length - i - 1;
}
@ngdoc directive
@name ngMinlength
@restrict A

@param {expression} ngMinlength AngularJS expression that must evaluate to a `Number` or `String`
                                parsable into a `Number`. Used as value for the `minlength`
                                {@link ngModel.NgModelController#$validators validator}.

@description

ngMinlength adds the minlength {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.
It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.

The validator sets the `minlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
is shorter than the integer obtained by evaluating the Angular expression given in the
`ngMinlength` attribute value.

<div class="alert alert-info">
**Note:** This directive is also added when the plain `minlength` attribute is used, with two
differences:
<ol>
  <li>
    `ngMinlength` does not set the `minlength` attribute and therefore HTML5 constraint
    validation is not available.
  </li>
  <li>
    The `ngMinlength` value must be an expression, while the `minlength` value must be
    interpolated.
  </li>
</ol>
</div>

@example
<example name="ngMinlengthDirective" module="ngMinlengthExample">
  <file name="index.html">
    <script>
      angular.module('ngMinlengthExample', [])
        .controller('ExampleController', ['$scope', function($scope) {
          $scope.minlength = 3;
        }]);
    </script>
    <div ng-controller="ExampleController">
      <form name="form">
        <label for="minlength">Set a minlength: </label>
        <input type="number" ng-model="minlength" id="minlength" />
        <br>
        <label for="input">This input is restricted by the current minlength: </label>
        <input type="text" ng-model="model" id="input" name="input" ng-minlength="minlength" /><br>
        <hr>
        input valid? = <code>{{form.input.$valid}}</code><br>
        model = <code>{{model}}</code>
      </form>
    </div>
  </file>
  <file name="protractor.js" type="protractor">
       var model = element(by.binding('model'));
       var input = element(by.id('input'));

       it('should validate the input with the default minlength', function() {
         input.sendKeys('ab');
         expect(model.getText()).not.toContain('ab');

         input.sendKeys('abc');
         expect(model.getText()).toContain('abc');
       });
  </file>
</example>