Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Problems with a mdb-select.

gmayas free asked 5 years ago


Hello:

I want to fill the Array public optionsSelect: Array ;

since

 ngOnInit() {
console.log('olsClientes: ', this.user.olsClientes.length);

for (var _i = 0; _i < this.user.olsClientes.length; _i++) {
  var olsClientes = this.user.olsClientes[_i];
  var inc = +_i;
  const data = {
    value: inc.toString(),
    label: olsClientes.ClaveCliente
  };
  // this.optionsSelect.push(data);
  this.optionsSelect = [...this.optionsSelect, {value: inc.toString(),label: olsClientes.ClaveCliente}];
  console.log('this.optionsSelect: ', this.optionsSelect);
  console.log('Data: ', data);
}

}

But the following error marks me:

ProductsListComponent.html: 7 ERROR TypeError: Can not read property 'concat' of undefined     at ClientBarComponent.ngOnInit (client-bar.component.ts: 64)     at checkAndUpdateDirectiveInline (core.js: 9250)     at checkAndUpdateNodeInline (core.js: 10514)     at checkAndUpdateNode (core.js: 10476)     at debugCheckAndUpdateNode (core.js: 11109)     at debugCheckDirectivesFn (core.js: 11069)     at Object.eval [as updateDirectives] (ProductsListComponent.html: 2)     at Object.debugUpdateDirectives [as updateDirectives] (core.js: 11061)     at checkAndUpdateView (core.js: 10458)     at callViewAction (core.js: 10699)

Waiting for your quick response.

Best regards.


Arkadiusz Idzikowski staff answered 5 years ago


Please make sure you initialized your optionsSelect array before using spread operator in ngOnInit hook. If that won't help please provide more code and reproduction steps or send a demo app on which I would be able to debug this problem. You can send it to a.idzikowski@mdbootstrap.com.

this.optionsSelect = [];


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 7.0.0
  • Device: mdb-select
  • Browser: Google Chrome
  • OS: All
  • Provided sample code: No
  • Provided link: No