0

With this reference: Angular2 - how to call component function from outside the app

I tried to call function outside my component. Function which I call has service call:

 private updateContact(contact) {
      this._myService.updateClientContacts(contact).subscribe(updateData => this._myService.getClientContacts());
    }

I tried call it doing this:

dataSourceOptions.transport = {
      read: function(e){
             e.success(griddata);
      },
      update: function (e) {
        // locate item in original datasource and update it
        griddata[getIndexById(e.data.ContactID)] = e.data;
        window['clientComponentRef'].zone.run(() => {window['clientComponentRef'].component.updateContact(griddata[getIndexById(e.data.ContactID)]).bind(this);});
        //on success
        e.success();
        // on failure
        //e.error("XHR response", "status code", "error message");
      }

I also try it without .bind(this) on this line of code:

 window['clientComponentRef'].zone.run(() => {window['clientComponentRef'].component.updateContact(griddata[getIndexById(e.data.ContactID)]).bind(this);});

but it didn't help.

but it returns error 405, and I cant access to myService and post edited item. Does anyone have idea how to solve that? Thanks!

Community
  • 1
  • 1
Yuniku_123
  • 269
  • 1
  • 5
  • 18

0 Answers0