Reputation: 2471
Which is better to use on route views
obj = { contact:true,about:false };
<div ui-view="contact" ng-if="obj.contact"></div>
<div ui-view="about" ng-if="obj.about"></div>
or
<div ui-view="contact" ng-include="obj.contact"></div>
<div ui-view="about" ng-include="obj.about"></div>
Both do the same work bring template on the main html.
Among them which one is better to use for this case and why?
Upvotes: 2
Views: 1027
Reputation: 486
ng-include
has a significant performance hit.
Look at this: Avoiding ng-include for Elegance and Performance
Upvotes: 0
Reputation: 5164
ng-include
is used to include an external HTML template, not to conditionally hide/show content. In this case, ng-if
is correct.
https://docs.angularjs.org/api/ng/directive/ngInclude
Upvotes: 3