Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 08-25-2018, 09:41 AM   #1
ajaxdns
Registered User
 
Join Date: Apr 2018
Posts: 1,360
What is the use of ngForTrackBy directive?

For iterating over a collection in Angular 2, the ngFor directive is used which instantiates a template once per item from the collection. If a data needs to be changed at some point in the collection, then a problem occurs because angular cannot keep a track of items in the collection and has no knowledge of the items which were added or deleted. This results in the deletion of all the DOM elements that are associated with the data and are again created. If the collection is big, then it becomes more complicated because a lot of DOM manipulation occurs which are expensive. So, to solve this problem, a trackBy function is used which takes the index and the current item as arguments and returns the unique identifier for this item.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ajaxdns is offline   Reply With Quote

Old 09-19-2018, 10:20 PM   #2
richardmsmith
Registered User
 
Join Date: May 2018
Posts: 288
NgForOf provides several exported values that can be aliased to local variables.
The NgForOf directive instantiates a template once per item from an iterable. The context for each instantiated template inherits from the outer context with the given loop variable set to the current item from the iterable.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
richardmsmith is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What do you mean by a structural directive in Angular 2? ajaxdns Javascript 0 08-25-2018 09:40 AM
What are directives? How to create and use custom Directive in Angular js. ajaxdns Javascript 0 08-25-2018 09:25 AM
Explain Directive scopes? ajaxdns Javascript 0 08-25-2018 09:20 AM
Explain ng-disabled Directive in AngularJS. designpluz Graphic Design 0 11-29-2017 08:07 PM
Explain ng-repeat directive. designpluz Graphic Design 0 11-29-2017 08:04 PM


All times are GMT -7. The time now is 10:09 AM.


Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.