title: Angular 2 - ES6 - trigger form validator depending on checkbox value
body: <p>What i'm trying to achieve is explained in <a href="https://stackoverflow.com/questions/32260082/how-to-trigger-form-validators-in-angular2">How to trigger Form Validators in angular2</a></p>
  
  <p>But in that, there's no explanation about how do you pass the checkbox state into the validator for the text box. My code is as follows</p>
  
  <p><strong>The Component:</strong></p>
  
  <pre><code>export class FormComponent { 
  
    static get annotations() {
          return [
              new Component ({
                  templateUrl: "./form.component.html",
                  directives: [FORM_DIRECTIVES],
              })
          ];
      }
  
      static get parameters() {
          return [[FormBuilder]];
      }
  
      constructor (formbuilder) {
          this.checkbox = new Control(false);
          this.name = new Control('', nameValidator(this.checkbox.value));
  
          this.myForm = formbuilder.group({
              checkbox: this.checkbox,
              name: this.name,
          });
  
          this.checkbox.valueChanges
          .subscribe({
              next: (value) =&gt; { this.name.updateValueAndValidity(); }
          });
      }
  }
  </code></pre>
  
  <p><strong>The Validator function</strong></p>
  
  <pre><code>function nameValidator(checkbox) {
      return function(control) {
          if (checkbox &amp;&amp; !control.value)
              return { required: true };
          return null;
      }
  }
  </code></pre>
  
  <p>But the updated checkbox value is not reflected in the validator function on calling <code>updateValueAndValidity()</code>. What am I missing here?</p>