Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

md-autocomplete ng-pattern="..." does not work

I have the issue with <md-autocomplete> component which is shown in this demo:

<md-autocomplete ng-pattern="..."> does not work. I would expect that if some text is entered into Tax field (like zzz) the field is be marked as red as only numbers [1..99] are accepted by regex ng-pattern="/^[1-9]\d?$/". Actually required works fine: when the field is empty, it is triggered as invalid.

like image 416
dma_k Avatar asked May 10 '17 17:05

dma_k


2 Answers

That seems to have been a bug with Angular Material. It was apparently fixed in 1.1.4:
ng-pattern for md-autocomplete #9755

Here's a working demo. All I did was update the two angular-material libraries.

https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.js
https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.css
like image 112
wwv Avatar answered Sep 20 '22 17:09

wwv


The issue with ng-pattern got fixed in version 1.1.14. I have updated the Demo and added latest angularjs-material.js

I have not changed ng-pattern, it remains same.

ng-pattern="/^[1-9]/"

Now the field will change to red if other than number is entered.

like image 20
Srikanth B Avatar answered Sep 21 '22 17:09

Srikanth B