I have a ng-pattern to enforce a particular format (for instance, IP v4 address):
<input ng-model="ip"
ng-pattern="/(([2][0-5]{2}|[2][0-4]\d|[01]?\d{0,2})\.){3}([2][0-5]{2}|[2][0-4]\d|[01]?\d{0,2})/">
</input>
The data comes from the DB but let's say that the requirement evolved and now IPv6 should be stored. I would have expected changing the regular expression but it removes the content of the input! Check this plunker (where you can see the losing-content effect): http://plnkr.co/edit/UPrU35
It is kind of the same thing as switching an input to required, I simply need users to comply to the new rules.
Question:
How should one proceed to apply ng-pattern but still keep the ng-model binding? (I want the form input to be invalid but no at the cost of losing its former content)