0

I use a JQuery Library (iCheck) and I want to do a directive for use it in my html component but it does not work .. My code : Directive.ts

import { Directive, ElementRef, HostListener, Input, AfterViewInit } from '@angular/core';

declare var jQuery: any;

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

export class IcheckDirective {
  constructor(private el: ElementRef) { }

  ngAfterViewInit() {
    jQuery(this.el.nativeElement).iCheck({
      checkboxClass: 'icheckbox_minimal',
      radioClass: 'iradio_minimal'});
    }
}

xxx.component.html

<label class="radio">
       <input type="radio" icheck name="filter" value="OF"> Other           </label>

IE : icheck is the selector name in my directive. I Use Angular 4.

user1814879
  • 984
  • 6
  • 23
  • 49
  • Try to follow the steps in this article: https://medium.com/@NetanelBasal/typescript-integrate-jquery-plugin-in-your-project-e28c6887d8dc – Himanshu Kumar May 29 '17 at 10:03
  • Thxx so much for this link ... But I dont see where he uses it in a html component like me .. I want use it in my html – user1814879 May 29 '17 at 11:13
  • The way you have setup is correct. What error are you getting? – Himanshu Kumar May 29 '17 at 11:18
  • I haven't error .. Its just the directive is not recognized in my component html .. I want to get something like http://icheck.fronteed.com/ in my button radio and checkBox – user1814879 May 29 '17 at 12:09

0 Answers0