how to integrate icheck into angular 6

0

I am new at angular and I want to give a bit of style to the text boxes and radio buttons, using the icheck library but I have found a problem when trying to create the directive because if I use more than one text box in a form always the last one that contains the directive remains with the focus activated and if I click on any part of the screen it is marked.

The directive:

declare var $: any;

@Directive({
  selector: '[icheck]'
})

export class IcheckDirective {
  $: any = $;
  constructor(el: ElementRef) {
    $(el.nativeElement).iCheck({
      checkboxClass: 'icheckbox_square-aero',
      radioClass: 'iradio_square-aero'
    });
  }
}

This is how I use the directive:

<label class="">
    <input name="radio" type="checkbox" value="1" icheck> Valor 1
</label>
<label class="">
    <input name="radio2" type="checkbox" value="1" icheck> Valor 2
</label>

This is what the result looks like:

Always the last combo stays with the focus and where click only activates and deactivates the last box, thanks for any help you can give me ..

    
asked by Ricardo Orellana 27.06.2018 в 00:07
source

0 answers