title: Using Angular 2 to bind to pattern attribute
body: <p>I'm have a country class that has a property defining a regular expression (string format) for a valid postal code for the associated country.</p>
  
  <p>I have an html select of the countries and am trying to bind the regular expression of the selected country to the pattern attribute of an input box for postal code.</p>
  
  <p>For some reason, the validation always shows as invalid (based on the presence of the ng-invalid class).  The regular expression definitely is not being validated as I've run the same regex in external validators and the validation has passed just fine.</p>
  
  <p>Here is some of the code.  (A <a href="http://plnkr.co/edit/RLwgoIkNiaye1NB4tnKX?p=preview" rel="nofollow">plunk of this is available here</a>)</p>
  
  <pre><code>export var COUNTRIES : Array&lt;ICountry&gt; = [
   {id: 1, name: "United States", zipRegEx: "^\\d{5}(-?\\d{4})?$", requireState: true},
   {id: 2, name: "Canada", zipRegEx: "^[ABCEFGHJKLMNPRSTVXY][0-9][ABCEFGHJKLMNPRSTVWXYZ]\\s?[0-9][ABCEFGHJKLMNPRSTVWXYZ][0-9]$", requireState: true},
   {id: 3, name: "Brazil", zipRegEx: "", requireState: false},
   {id: 4, name: "Australia", zipRegEx: "^(\\d{4})$", requireState: false},
   {id: 5, name: "Faroe Islands", zipRegEx: "^\\d{2}$", requireState: false},
   {id: 6, name: "Papua New Guinea", zipRegEx: "", requireState: false}
  ];
  
  &lt;label&gt;Country&lt;/label&gt;
  &lt;select [ngModel]="address.country.id" (change)="countryChange($event)" required&gt;
    &lt;option value=""&gt;-- Select a Country --&lt;/option&gt;
    &lt;option *ngFor="#country of countries | async | orderBy:{property:'name'}" [value]="country.id" &gt;{{country.name}}&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;
  
  &lt;label&gt;Postal Code&lt;/label&gt;
  &lt;input type="text" [(ngModel)]="address.postalcode" [pattern]="address.country?.zipRegEx" /&gt;&lt;br&gt;
  </code></pre>
  
  <p>If I use the developer tools, I can see that the binding is working and that the value of pattern is actually being set; however, the ng-invalid class is not properly being applied.</p>
  
  <p>Any thoughts on how this can work using the pattern attribute?</p>