Wednesday, April 10, 2019

viewChild, viewChilden, contentChild

View Child:

Supported selectors include:
  • any class with the @Component or @Directive decorator
  • 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:

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



 viewChildren

https://stackoverflow.com/questions/51252429/angular-viewchild-for-dynamic-elements-inside-ngfor



contentChild

https://www.udemy.com/the-complete-guide-to-angular-2/learn/lecture/6656114#overview


RouterModule.forChild(routes) and RouterModule.forRoot(routes)

https://medium.com/@cyrilletuzi/understanding-angular-modules-ngmodule-and-their-scopes-81e4ed6f7407 (VVI)

Preload Lazy loading: 

angular tutorial 299 (very important for lazy load module fating load)


No comments:

Post a Comment

Autoboxing and Unboxing

  Autoboxing  is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper cl...