title: Problem with conditional required attribute in Angular
body: <p>Fairly new to Angular. </p>
  
  <p>I'm trying to mark an input field with an optional "required" attribute, which will be controlled by a property of the same name in the component. </p>
  
  <pre><code>@Input() required: boolean = true;
  </code></pre>
  
  <p>Simple, right? That's what I thought.</p>
  
  <p>This is working:</p>
  
  <pre><code>&lt;input 
      id="test123" name="test123"
      [required]="required ? '' : null"
      [(ngModel)]="test123"
  /&gt;
  </code></pre>
  
  <p>Whereas this is not:</p>
  
  <pre><code>&lt;input 
      id="test456" name="test456"
      [required]="required ? '' : null"
    /&gt;
  </code></pre>
  
  <p>Obviously, it needs an ngModel for the required to work, but I don't really need a model for this input; I'm just using the input for capturing keyboard events for an auto-complete. </p>
  
  <p>Should I just make a fake model for it in the component? Or is there another way around this? </p>
  
  <p><a href="https://stackblitz.com/edit/angular-ylufjn" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-ylufjn</a></p>