samedi 8 septembre 2018

How to make a checkbox checked dynamically after passing a value from another component in angular 6?

My second.html:

          <div class="col-lg-4 col-md-4 col-sm-4"> 
            <input type="checkbox" class="checkmark" name="nond" [checked]="r=='true'"  (change)="nond($event, check)">
          </div>

My second.ts:

   Flag(): void {
this._call.getflag()
  .subscribe(r => {
    this.Flag = r;
    let value = true;
    if (r == value) {
      let data = {
        'flag': r
      };
      let obj = this.$modal.show(DComponent, undefined, data)
        .subscribe(r => {
          if (r.click === 'CONTINUE') {
            obj.unsubscribe();
          }
        });
    }

  });
}

I have a checkbox in this html page. In my typescript file, on initialize, Im calling an API function & it will return a boolean value. Based on that I need to check my checkbox & should pass the checked value. So can anybody please tell me how to do this in angular 6?




Aucun commentaire:

Enregistrer un commentaire