0

How would someone access a component of a childs child.

parent > child > interesting child

I used ViewChild and it shows the child and its child, but I cannot access childs child public attributes.

this.list - returns ok

this.list.infinityList returns undefined

Why?

enter image description here

puppeteer701
  • 1,225
  • 3
  • 17
  • 33
  • Should probably be using a service for that sort of thing – Z. Bagley Oct 18 '17 at 23:43
  • Can you give me an example, because the idea is: Change a property on data and watch for the change on child, but cannot do this easily with angular 2 as in angular 1. I dont want to use the subject, as I need to send the whole modified object, I just want to modify one property and have the child to act on the change. – puppeteer701 Oct 18 '17 at 23:48
  • 1
    Check out my example here: https://blogs.msmvps.com/deborahk/build-a-simple-angular-service-to-share-data/ The plunker is here: https://plnkr.co/edit/KT4JLmpcwGBM2xdZQeI9?p=preview – DeborahK Oct 18 '17 at 23:53
  • As stated by @Z.Bagley you could go with **Shared Service** If you have a Lazy Loaded Module you need to follow an approach, https://angular-2-training-book.rangle.io/handout/modules/shared-di-tree.html Eg: The problem with shared service in Lazy loaded module: https://plnkr.co/edit/L2ypUQZiltSPXnLlxBoa?p=preview https://plnkr.co/edit/kqat7k4YhLSDKrjr8x2f?p=preview – Ramasamy Kasiviswanathan Oct 19 '17 at 00:42
  • Post on StackOverflow, https://stackoverflow.com/a/39672927 Have a look at this as well, https://angular.io/guide/ngmodule#prevent-reimport-of-the-coremodule – Ramasamy Kasiviswanathan Oct 19 '17 at 00:51

0 Answers0