ng-minlength完成后计数器更新......它最初不会更新。 应该是什么问题..
<div class="col-xs-12">
<div class="form-group">
<label class="_500">Title of the {{ ::CreatePostVm.postTypeTitle }}</label>
<input name="postTitle" type="text" autofocus ng-model="CreatePostVm.post.title" placeholder="Write the title of your {{ ::CreatePostVm.postTypeTitle }} here..." ng-minlength="10" ng-maxlength="100" minlength="10" maxlength="100" required class="form-control" />
<div class="row">
<div class="col-xs-12 col-xs-8">
<div ng-messages="createPost.postTitle.$error" role="alert" class="ng-validation-messages m-t-xs">
<div ng-message="required">Title is needed to summarize your {{ ::CreatePostVm.postTypeTitle }}</div>
<div ng-message="minlength">Title should be minimum 10 characters long</div>
<div ng-message="maxlength">Title should be maximum 100 characters long</div>
</div>
</div>
<div class="col-xs-12 col-xs-4">
<div class="helper-text text-right">
<span class="small text-muted">
<span>{{ CreatePostVm.post.title.length || 0 }}</span>/100
</span>
</div>
</div>
</div>
答案 0 :(得分:3)
ng-minlength是一个验证指令,如果输入有效则只有值更新为ng-model,如果值无效,则不会更新为模型。
有关详情,请查看this link。
有一个minLength示例,如果minlength不满意,则模型值显示为空白。