Why can not I concat data to observable array in knockout
The observableArray
does not support the concat
method. See the documentation for the officially supported array manipulation methods.
However what you can do is to call concat
on the underlying array and then reassign this the new concatenated array to your observable:
self.listOfReports(self.listOfReports().concat(data));
The linked example works because the self.Products().concat(self.Products2())
were used in a loop. If you just write self.listOfReports().concat(data);
it still concatenates but you just thrown away the result and don't store it anywhere, that is why you need to store it back to your observableArray.