Scottie
Scottie

Reputation: 11308

Alternative to ng-repeat if I don't need scope

I have a situation where I am generating a LOT of rows and columns using Angular and the performance is terrible!!

I'm assuming that it's because my ng-repeat is creating a new scope for each of the elements that it creates, however, this particular function doesn't need to watch anything. I'm simply using ng-repeat as a loop to generate HTML that will never change.

Is there another angular method that I can use to loop through model data and generate HTML without using ng-repeat that will improve performance?

Upvotes: 3

Views: 4965

Answers (2)

batmaniac7
batmaniac7

Reputation: 422

You can create a directive which will accept the ng-repeat values and then do whatever you want to do in that directive e.g. create a table which will have those values.

Upvotes: 1

xsh.7
xsh.7

Reputation: 6250

You actually need the scope to access the data for the current iterations item.

However, as your data never changes, you might get take a look at bindonce or the slyRepeat directive.

Upvotes: 0

Related Questions