The format of your regex is slightly off. When a string is passed to the ng-template, it automatically ends in ^ and $ (see the documentation ), so you do not need these characters. You also don't need slashes at the beginning or end, but you need to wrap the regular expression in a string. Finally, if you are trying to match only numbers 1 through 5, you can simplify your ng pattern as follows:
ng-pattern="'[1-5]'"
However, if you want to match any number of digits from 1 to 5, you will need to use one of the following values:
// zero or more digits, from 1-5 ng-pattern="'[1-5]*'" // one or more digits, from 1-5 ng-pattern="'[1-5]+'"
source share