View Child:
Supported selectors include:- any class with the
@Componentor@Directivedecorator - a template reference variable as a string (e.g. query
<my-component #cmp></my-component>with@ViewChild('cmp')) - any provider defined in the child component tree of the current component (e.g.
@ViewChild(SomeService) someService: SomeService)
REF:
- https://stackblitz.com/edit/viewchild-angular-6-example?file=src%2Fapp%2Falert%2Falert.component.html
- https://alligator.io/angular/viewchild-access-component/
- http://www.eduforbetterment.com/sharing-data-via-viewchild-in-angular/ (VVI)
ViewChild:
https://dev.to/danielpdev/how-to-use-viewchild-decorator-in-angular-9-i0 (*******) (desc about static= true and false)
When should you use { static: true } ?
One usecase could be, when you need to access a child element's
instance fields that don't rely for their values on inputs from other
elements.like i use in datatable for cellTemplat. Here i need only ref . not need viewchild element value.. (study https://dev.to/danielpdev/how-to-use-viewchild-decorator-in-angular-9-i0 for beter understanding)
When you assign "true" you can get ref in ngoninit lifecycle hook
No comments:
Post a Comment