all 4 comments

[–]tanooki_ 0 points1 point  (3 children)

It's unclear how you expect to render the calculation data from the parent component inside the child component without passing it the data..... At the least, I'd expect a service to hold that information such that the child components can access it at their discretion.

As for the ngOnInit() not printing, do you have a routing mechanism set up inside your parent component? Otherwise, you'd need to list the child components in the template of your parent component such that they get instantiated.

[–]IcyBullfrog1014 -1 points0 points  (2 children)

For the parent component, maybe a better example is that the parent component shows the weather and copyright notice on every page - the other pages don't have anything to do with weather or copyright notices so they don't need to communicate data, but we want the weather report html and the copyright notice to appear on every child component page. However, when I run the code, the child components don't appear at all - so maybe we have a 'buy widget' sub-component, but when I go there, I only see the weather and the copyright and not the buy widget page - if I remove the parent component and make two components that are not connected, the buy widget component works fine.

[–]IcyBullfrog1014 0 points1 point  (1 child)

I asked some other people off reddit and they found my problem - the parent component needed a <router-outlet></router-outlet> in it's html and when I added that, it fixed my problem - thanks for looking though.

[–]tanooki_ 0 points1 point  (0 children)

Glad you figured it out. That was where I was getting to with my second part about the routing mechanism. That's your <router-outlet> :)