Hi,
I'm trying to load data using custom read function in DataSource transport. I have to use the angular service due to usage of angular $http interceptors providing the user authentication mechanism.
The problem start when I try to use the controller's "MyService" field in the read function, as shown bellow:
export class CountersController {
constructor(private $scope: ng.IScope,
private $q: ng.IQService,
myService: LonginusCountersApp.Services.IMyService) {
this.MyService = myService;
}
private MyService: LonginusCountersApp.Services.IMyService;
public counterGroups = new kendo.data.HierarchicalDataSource({
transport: {
read: function (options) {
this.MyService.GetCounters().then((data: ng.IHttpPromiseCallbackArg<{}>) => {});
}
}
});
}
The problem is, that on Runtime i get error, that I try to call GetCountes() on undefined or null object (MyService).
It there any way to pass the service reference to the read function?
I followed the response to the thread: http://www.telerik.com/forums/unable-make-treeview-work-with-angulajs-service
but it seems not to work, or at least not to work with TypeScript.
Do You have any idea, how to achieve this?
Best regards
Marcin Danek