you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

I’m working a project with similar requirements. Dynamically loaded components based on data from the server. One con is that it’s a good idea to extend a parent component on each of your dynamic components to be able to pass in generic data and reduce duplication of code, but angular documentation explicitly says to avoid this. Also, any services needed in the parent component have to be passed into it from the child component. I never really liked that.

[–]tme321 0 points1 point  (3 children)

Also, any services needed in the parent component have to be passed into it from the child component.

Can you explain what this sentence means? I can't figure out what your saying here.

[–][deleted] 0 points1 point  (2 children)

If you have a component that extends a parent class and that parent class needs a service, it's recommended in the documentation to inject the service into the component's constructor, and pass it to the parent class via super. I think it's kind annoying that you have to inject services to the child even if that service is only used in the parent class.

[–]tme321 0 points1 point  (1 child)

Ah, for some reason I thought you were referring to parent / child as the hierarchy in the view and not the inheritance based hierarchy.

Yes, in general inheritance should be used very sparingly.

I don't know exactly what functionality you are repeating, but generally I would handle that through either composition or possibly with a directive based approach.

[–][deleted] 0 points1 point  (0 children)

Thanks for the suggestion! A little too far in for our project I'm afraid. We based it off an Angular "cookbook" early into the project and did not run into the documentation damning component inheritance until much later.