The angular method call parent component sub-assemblies - using @ViewChild decorator modified sub-assembly, access method, call
In addition ViewChild can also get DOM, operating DOM, see: https://www.cnblogs.com/monkey-K/p/11567098.html
1. html used #var subassembly is labeled
<div style="border: 1px solid red">
<p> subcomponents: </ P> >
<app-login #login></app-login>
<Button (the Click) = "userChildMethod ()" > calling method subassembly </ button>
</div>
2. js used @ViewChild decorator
@ViewChild('login', null) loginComponent: any
userChildMethod() {
// call the sub-assembly method
this.loginComponent.loginIn()
}
注: angular 中如果不知道 类型 就定义为 any