Basit
Basit

Reputation: 17184

Ionic2 + Angular2 - Attempted to assign to readonly property

I'm using ionic refresh api, which lets page to be pulled and refresh with updates.

angular2 page on refresh method. I want to clean existing rows and then add new rows with .push() method. when I clean property with this.rows = [] I get following error.

8 470644 error EXCEPTION: TypeError: Attempted to assign to readonly property. in [rows in ListPage@25:30]

Is there any other way of cleaning previous array for this.rows property?

Upvotes: 1

Views: 1970

Answers (1)

dfsq
dfsq

Reputation: 193261

So don't reassign rows array, modify existing one:

this.rows.length = 0;

Setting array length to 0 effectively clears array (in place, by modifying it).

Upvotes: 2

Related Questions