Robert
Robert

Reputation: 393

Create TypeScript class in separate file

I have ag-grid in Angular and CustomFilter. CustomFilter is defined as function in the same file. But this file is large. I want to move CustomFilter to separate file.

This is my code, column definition in Angular in TypeScript:

 "colId": column.FieldName,
 "width": column.Width,
 "filter": CustomFilter,

And definition CustomFilter is in the same file, but outside class in which column definition is placed:

function CustomFilter() {
}

CustomFilter.prototype.setGuiTemplate = function (params) {

}
...

And I want to move CustomFilter to another file and import this file.

Upvotes: 0

Views: 330

Answers (1)

Mariano Calcagno
Mariano Calcagno

Reputation: 420

you can create a ts file and export your function like this

    export function CustomFilter(params) {
        // your code here
    }

then import the function in your code (the IDE will suggest you the import)

Upvotes: 2

Related Questions