Problems with a mdb-select.


Topic: Problems with a mdb-select.

gmayas asked 6 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 6 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
  • User: 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
Tags