Justin Tyme
Justin Tyme

Reputation: 163

What are the performance advantages in Angular to create a directive instead of using ng-include?

<div ng-include="'blah.html'">

vs.

<blah> </blah>

What are the performance advantages to the latter?

Upvotes: 1

Views: 214

Answers (1)

XrXr
XrXr

Reputation: 2067

In general, if you just want the content of the template, its faster to create a simple directive that just use templateUrl. However, ng-include offers some advance features that a simple directive don't have such as the $includeContentLoaded event and the onload call back.

Here is the performance benchmark that prove templateUrl is faster. dummy is the simple directive

Upvotes: 1

Related Questions