AngularJS trims the input by default, so you need to use ng-trim="false"
in order to pass leading and trailing whitespace to your pattern
regex.
See documentation:
ngTrim (optional)
If set to
false
Angular will not automatically trim the input. This parameter is ignored forinput[type=password]
controls, which will never trim the input.(default: true)