Invoke custom method

Hi. I’m trying to invoke a custom method following documentation in https://www.radzen.com/documentation/custom-controller/ and I confused about where include the route to custom method. May be the example is not updated to actual version of Radzen?

I will appreciate your help.

Regards

Hi Carlos,

We are using the data source url as root url in this article with /odata/ part removed. You can use your own pattern just make sure that the url is matching what is specified in the Root attribute of the custom controller.

Best Regards,
Vladimir

Hi Vladimir,

Doubt is about getData function used to call routed url. I don`t find same code structure used in the sample to extend with getData method:

export class MainComponent extends MainGenerated {
constructor(injector: Injector, private http: HttpClient) {
super(injector);
}
}

Hi Carlos,

You need to add these two imports:

// Import HttpClient and HttpParams which are needed to make HTTP calls.
import {HttpClient, HttpParams} from ‘@angular/common/http’;
// Import the environment to get the server URL
import {environment} from ‘…/…/environments/environment’;

Inject HttpClient in the constructor:

constructor(injector: Injector, private http: HttpClient) {
super(injector);
}

And add getData method.

Best Regards,
Vladimir

Hi Vladimir. It’s working perfect now!

Regards