@Component 和 Class 之间的 angular2 关系
angular2 relationship between @Component and Class
组件控制器class和组件之间的关系是如何形成的。是不是简单的基于这样的定位,无论什么class出现在一个给定的组件之后,它都会成为它之前定义的组件的组件控制器class。如果您在一个 js 文件中有多个组件,它是如何工作的。如何将 js 文件中任意位置的 class 关联到组件。
同理,是否存在子组件这样的东西,在这种情况下,这些子组件是否从父组件继承某些东西,更具体地说,是从父组件的组件控制器 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
具有结构:
@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.
组件不继承。组件 组成 。搜索 inheritance vs. composition(但我相信你知道这一点)。
class 构造函数中声明了某种父类。这是一个例子 http://victorsavkin.com/post/118372404541/the-core-concepts-of-angular-2:
class Component {
constructor(sibling:SiblingCmp,
@Parent parent:ParentCmp,
@Ancestor ancestor:AncestorCmp) {
}
}
组件控制器class和组件之间的关系是如何形成的。是不是简单的基于这样的定位,无论什么class出现在一个给定的组件之后,它都会成为它之前定义的组件的组件控制器class。如果您在一个 js 文件中有多个组件,它是如何工作的。如何将 js 文件中任意位置的 class 关联到组件。
同理,是否存在子组件这样的东西,在这种情况下,这些子组件是否从父组件继承某些东西,更具体地说,是从父组件的组件控制器 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
具有结构:
@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.
组件不继承。组件 组成 。搜索 inheritance vs. composition(但我相信你知道这一点)。
class 构造函数中声明了某种父类。这是一个例子 http://victorsavkin.com/post/118372404541/the-core-concepts-of-angular-2:
class Component {
constructor(sibling:SiblingCmp,
@Parent parent:ParentCmp,
@Ancestor ancestor:AncestorCmp) {
}
}