I'm trying to use packery in one of my Angular2 projects. However I just can't seem to get it to work in a directive. This is my packery.directive.ts file
/// <reference path="../../../typings/packery/packery.d.ts" />
import { Directive, ElementRef } from '@angular/core';
@Directive({
selector: '[packery]'
})
export class Packery {
constructor(el: ElementRef) {
jQuery(el.nativeElement).packery({
itemSelector: '.grid-item',
gutter: 10
});
}
}
The code doesn't work although it initializes when I use it without the options. i.e.
.....
export class Packery {
constructor(el: ElementRef) {
jQuery(el.nativeElement).packery();
}
}
However, with the options, I'll get an error
Supplied parameters do not match any signature of call target.
The typings file already has the types declared as optional.
declare module "packery" {
interface PackeryOptions {
itemSelector?: string;
gutter?: number;
......................
Appreciate it if someone can lead me to the direction of correctly implementing a jQuery plugin in TypeScript. Thanks.