typescript - RXJS and Angular: Take a number of elements in an array -


i'm trying wrap head around rxjs.

i'm getting array of things via http request.

but i'm having trouble taking number of objects.

here's method.

getthingsbyid(id: number): observable<ithing[]> { return this._http.get(this.url + id + '/things)   .map((response: response) => <ithing[]>response.json())   .take(20); } 

when try take 20 of things of them.

what doing wrong?

thanks!

try array.slice() method:

getthingsbyid(id: number): observable<ithing[]> {   return this._http.get(`${this.url}${id}/things`)     .map((response: response) => <ithing[]>response.json().slice(0, 20)); } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -