title: Check if NgControl is required
body: <p>I've got several custom components that wrap PrimeNG components for various reasons. Some instances of my components are used in reactive forms, and the field's &quot;requirement&quot; is set using <code>Validators.required</code> validator.</p>
  <p>PrimeNG components provide a <code>required</code> attribute.</p>
  <p>How can I inspect my component's NgControl for the required validator?  There is <code>.disabled</code> and <code>.invalid</code>, but <code>.invalid</code> could mean anything.</p>
  <p>Here I what I'm using now, which works for dropdowns, but would be incorrect for any other type of input.</p>
  <pre class="lang-js prettyprint-override"><code>@Component({
    selector: 'my-component',
    templateUrl: 'my.component.html'
  })
  export class MyComponent implements OnInit, ControlValueAccessor {
    
    @Input()
    public disabled: boolean
    @Input()
    public required: boolean
  
    constructor(
          @Optional() @Self() public ngControl: NgControl
    ) {
          if (this.ngControl != null) {
              this.ngControl.valueAccessor = this;
          }
      }
  
      ngOnInit() {
          if (this.ngControl) {
              this.required = this.ngControl.invalid;
              this.disabled = this.ngControl.disabled;
          }
      }
  }
  </code></pre>
  <p>I'm sure there is a better way to do this, but I don't see how.</p>