0

What is the preferred pattern for creating a repeater in ng2? I was thinking that I might do this with NgFor but NgFor is deprecated according to angular.io: https://angular.io/api/common/NgFor/. However, the same page on angular.io doesn't state the repeater pattern that should be used as an alternative. Can anyone here provide some insight on the latest patterns being used to implement repeaters in ng2 apps?

user8334943
  • 1,467
  • 3
  • 11
  • 21

1 Answers1

1

In most cases, you want to use the short-cut version: *ngFor. Behind the scenes, this is implemented as ngForOf. If you stick to the short-cut version, you don't have to worry about the "behind the scenes" changes.

See this link for more information: What is Angular [ngForOf] usage

DeborahK
  • 57,520
  • 12
  • 104
  • 129
  • I believe the `ngFor` deprecation applies to `*ngFor` as well, but I'm not totally sure. – Kevin Jul 27 '17 at 17:15
  • No. Check out the link above. Or the docs here: https://angular.io/api/common/NgForOf – DeborahK Jul 27 '17 at 17:16
  • Yeah as you responded I realized that. – Kevin Jul 27 '17 at 17:17
  • a basic use case from my perspective would be to display a parent div with several formatted child divs of the same type with different data. can you post a url that provides a good sample implementation along these lines? – user8334943 Jul 27 '17 at 17:22
  • This sounds like a different question. If so, could you create a new question and include some code outlining what you are trying to do? (Or if it is not really a new question, add some code here.) – DeborahK Jul 27 '17 at 17:24
  • hi deb, for example, display first name of each user in a collection in repeating divs. the following implementation is not valid but should show what I'm looking for:
    {user.FirstName}
    – user8334943 Jul 27 '17 at 17:29
  • Could you post this as a new question because my answer to this does not match with this posted title. Post the link here and I'll post you some sample code. – DeborahK Jul 27 '17 at 17:37