The Difference Between @ViewChildren and @ContentChildren



By Josh Morony

The title of this article doesn’t have quite the same air of excitement about it when compared to say Batman vs Superman, but it’s a concept I struggled with for a while and I felt that it is worthy of its own blog post.

When building an application with Ionic (or more generally, with Angular) you may come across the following annotations:
  • @ViewChild

  • @ViewChildren

  • @ContentChild

  • @ContentChildren

I think the difference between “child” and “children” is reasonably obvious, the plural form would just indicate more than one, but what is the difference between content and view? All of these perform the same general function, and that is to grab a reference to something in your template. With standard Javascript, you might do something like:

Read the full article...

Share on Google Plus

About www. codeandyou.com

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment