merge two object arrays with Angular 2 and TypeScript?



I have gone across the JavaScript questions on this topic, this question is specifically about Angular2 with TypeScript.

What I am trying to do is to concatenate the json objects to an array.

My code looks something like this,

public results: [];

public getResults(){
    this._service.get_search_results(this._slug, this._next).subscribe(
            data => {
                this._next =;
            err => {

How can I concatenate data.results to this.results with typescript and angular?

this._slug and this._next are set on class.



With angular 6 spread operator and concat not work. You can resolve it easy:


Answered By – MooN

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More