Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 relationship between @Component and Class

How is the relationship between a component controller class and the component is formed. Is it simply based on the positioning that whatever class comes after a given component, it becomes the component controller class for the component defined before it. How does it works if you have multiple components in a single js file. How do you associate a class anywhere in the js file to a component.

Along the same lines, is there such a thing as child components and in that case do these child components inherit something from parent components and more specifically from the component controller class of parent component.

like image 774
adeelmahmood Avatar asked Nov 30 '25 16:11

adeelmahmood


1 Answers

How is the relationship between a component controller class and the component is formed. Is it simply based on the positioning that whatever class comes after a given component, it becomes the component controller class for the component defined before it.

Yes.

How does it works if you have multiple components in a single js file

Have the structure:

@Component ...
class Foo ...

@Component ...
class Bar ...

Is there such a thing as child components and in that case do these child components inherit something from parent components and more specifically from the component controller class of parent component.

Components don't inherit. Components compose. Search inheritance vs. composition (but I sure you know this).

Also see : https://github.com/Microsoft/TypeScript/issues/2249

like image 190
basarat Avatar answered Dec 03 '25 06:12

basarat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!