0

Please or Register to create posts and topics.

How do I create a callback if the main class uses this.

Hi,

In my class I have this method

loadPagination(pagination: Pagination) {
    this.removeAction();
    this.loadingIndicator = true;
    this.customerService.getCustomersPagination(pagination).subscribe(
      result => this.onPaginationDataLoadSuccessful(result),
      error => this.onDataLoadFailed(error)
    );
 }

I want to create a server that calls this method. My service:

@Injectable()
export class PaginationService {
    private callback: (pagination: Pagination) => void;

    public setCallback(callback: (pagination: Pagination) => void) {
        this.callback = callback;
    }
    public call() {
        console.log(this.callback(new Pagination()));
    }
}

When the call () service is called I get an exception because this is not the main class.

I have been trying for 2 days now to solve the problem, unfortunately I have not found anything that I can implement.

Regards Ingo