Ui.list load method: url parameter cannot be a function?

import { Component, ElementRef, OnDestroy, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
import { environment } from '../.environments';

@Component({
  selector: 'test',
  template: ""
})
export class Component implements OnDestroy, OnInit, OnChanges {
  private ui: webix.ui.list;

  constructor(root: ElementRef) {
    this.ui = <webix.ui.list>webix.ui({
      container: root.nativeElement,
      view: "list",
      height: 650,
      width: 215,
      scroll: false,
      template: "#start# #end#",
      }
    });
  }

  ngOnInit() {
    this.ui.resize();
  }

  ngOnChanges(changes: SimpleChanges) {
    //ERROR
    this.ui.load(function () {
      let endpoint = environment.api;
      let path = endpoint + '/get';
      let params = { "param1": "xyz" };

      var promise = webix.ajax().get(path, params);

      promise.catch(function (err) {
        console.log('Failed to load data');
      });

      return promise;
    });
  }

  ngOnDestroy() {
    this.ui.destructor();
  }
}

Using Webix v 10.0.1
Loading data using this.ui.load() throws an error because it expects url as a string, but according to the documentation the url parameter can be set as a function. So what am I missing here?

Hello @username12345 ,
I can confirm the issue when TS is used. It will be fixed in our next patch release (Webix 10.0.2).
Thank you for noticing.

1 Like

Hello @username12345,

As a heads-up, Webix 10.0.2 is now available for download - the typings have been adjusted accordingly, and the load() method now accepts correct arguments.

1 Like