I am writing my question again because earlier it made little sense and I wasn't very clear.
I am receiving data from API that looks something like this:
{"photos":[{"id":1,"title":"photo_1_title"}]}
So, in my code, I have a photos
variable, and a method called getPhotos()
I am using infinite scroll so when I reach the bottom of the page, I call getPhotos()
again.
photos: any;
getPhotos() {
this.photoService.getPhotos()
.subscribe(
photos => this.photos = photos
)
}
So if the next time I call it, I get back {"photos":[{"id":2,"title":"photo_2_title"}]}
, then I am trying to set this.photos
to be
{"photos":[{"id":1,"title":"photo_1_title"}, {"id":2,"title":"photo_2_title"}]}
can someone help me with why
jsfiddle.net/ca46hLw9 doesn't work? I thought assign is supposed to merge contents of an object together right?