ng-maxlength

ng-maxlength screws up my model

狂风中的少年 提交于 2019-12-17 17:40:54
问题 I'm trying to do a simple textarea with "so many chars remaining" along with validation. when I use ng-maxlength to validate my form, it resets my charcount as soon as the length hits the max length. Here's the plunkr Any workarounds? <body ng-controller="MainCtrl"> <div ng-form="noteForm"> <textarea ng-maxlength="15" ng-model="result"></textarea> <p>{{15 - result.length}} chars remaining</p> <button ng-disabled="!noteForm.$valid">Submit</button> </div> </body> 回答1: When your textarea exceeds

ng-maxlength screws up my model

亡梦爱人 提交于 2019-11-28 04:40:28
I'm trying to do a simple textarea with "so many chars remaining" along with validation. when I use ng-maxlength to validate my form, it resets my charcount as soon as the length hits the max length. Here's the plunkr Any workarounds? <body ng-controller="MainCtrl"> <div ng-form="noteForm"> <textarea ng-maxlength="15" ng-model="result"></textarea> <p>{{15 - result.length}} chars remaining</p> <button ng-disabled="!noteForm.$valid">Submit</button> </div> </body> Mark Rajcok When your textarea exceeds 15 characters, result becomes undefined — that's just how the ng-min/maxlength directives work.