{"id":1994,"date":"2019-08-15T10:57:11","date_gmt":"2019-08-15T08:57:11","guid":{"rendered":"https:\/\/www.thecodecampus.de\/blog\/?p=1994"},"modified":"2023-12-20T19:57:44","modified_gmt":"2023-12-20T18:57:44","slug":"angular-viewchild-static-property-in-ng8","status":"publish","type":"post","link":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/","title":{"rendered":"Angular ViewChild &#8211; static property in ng8"},"content":{"rendered":"<p>Some of you might have stumbled upon an unexpected error message, while updating your project from ng7 to ng8. We all know that. Everything runs smoothly and we use the last 10 minutes before heading off for the update. Not a major issue. Already having packed your stuff and ready to head home, you get this message.<\/p>\n<p><a href=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1995 size-full\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg\" alt=\"\" width=\"753\" height=\"134\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg 753w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild-300x53.jpg 300w\" sizes=\"auto, (max-width: 753px) 100vw, 753px\" \/><\/a><\/p>\n<p>What went wrong? Lets have a look, as knowing this might save you a little time and surprises.<\/p>\n<p style=\"padding: 2px 6px 4px; color: #555555; background-color: #eeeeee; border: 2px solid #dddddd; text-align: justify;\"><strong>Quick Fix<\/strong><br \/>\nTo solve the problem fast without much reading, you just have to add a static property <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code> or <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: true}<\/code> into every @ViewChild\/@ContentChild decorator. <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: true}<\/code> forces the initialization of the component\/directive already in ngOnInit, <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code> changes the timing to ngAfterViewInit for @ViewChild and ngAfterContentInit for @ContentChild.<\/p>\n<h3>Whats the Problem?<\/h3>\n<p>So our problem is the <strong>@ViewChild<\/strong> or the <strong>@ContentChild<\/strong> property decorator. In short these decorators make it possible to include any components or directives, which are a direct child to the component. With @ViewChild you include elements you added to the component yourself. Contrary to that @ContentChild includes a reference to content that has been placed in a component with the &lt;ng-content&gt;-tag.<\/p>\n<p>To learn in depth what they do and how to use them you can check it out <a href=\"https:\/\/blog.angular-university.io\/angular-viewchild\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p>Lets have a look at an example we used earlier in this blogpost about <a href=\"https:\/\/www.thecodecampus.de\/blog\/content-projection-in-angular\/\">Content Projection in Angular<\/a>. The following code shows the old version in Angular 7, where we included three directives with the selectors appCardBody, appCardFooter and appCardHeader.<\/p>\n<pre class=\"lang:js range:1-50 decode:true\" title=\"card.component.ts\" data-url=\"card.component.ts\">import {\r\n  Component,\r\n  ContentChild,\r\n  Directive,\r\n  OnInit,\r\n  AfterContentInit,\r\n} from '@angular\/core';\r\n\r\n@Directive({\r\n  selector: '[appCardBody]'\r\n})\r\nexport class CardBodyDirective {\r\n}\r\n\r\n@Directive({\r\n  selector: '[appCardFooter]'\r\n})\r\nexport class CardFooterDirective {\r\n}\r\n\r\n@Directive({\r\n  selector: '[appCardHeader]'\r\n})\r\nexport class CardHeaderDirective {\r\n}\r\n\r\n@Component({\r\n  selector: 'app-card',\r\n  templateUrl: '.\/card.component.html',\r\n  styleUrls: ['.\/card.component.css']\r\n})\r\nexport class CardComponent{\r\n  @ContentChild(CardHeaderDirective) header?: CardHeaderDirective;\r\n  @ContentChild(CardBodyDirective) body?: CardBodyDirective;\r\n  @ContentChild(CardFooterDirective) footer?: CardFooterDirective;\r\n\r\n  constructor() {}\r\n}<\/pre>\n<p>To show both decorators we also included In the Card Component as @ViewChild in app.component.ts as followed:<\/p>\n<pre class=\"lang:js range:1-24 decode:true\" title=\"app.component.ts\" data-url=\"app.component.ts\">import {AfterContentInit, AfterViewInit, Component, ContentChild, OnInit, ViewChild} from '@angular\/core';\r\nimport {CardBodyDirective, CardComponent, CardFooterDirective, CardHeaderDirective} from \".\/card\/card.component\";\r\n\r\n@Component({\r\n  selector: 'my-app',\r\n  templateUrl: '.\/app.component.html',\r\n  styleUrls: [ '.\/app.component.css' ]\r\n})\r\nexport class AppComponent{\r\n  @ViewChild(CardComponent)card: CardComponent;\r\n\r\n  name = 'Angular';\r\n}<\/pre>\n<p>So the application is running great and we decide to update from Angular 7 to Angular 8. After the update is finished we see, that the @ViewChild and @ContentChild decorators complain about a shortage of\u00a0 arguments. Why is that? Whats happenig here?<\/p>\n<p>@ViewChild in app.component.ts:<\/p>\n<p><a href=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/viewChildError.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2006\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/viewChildError.jpg\" alt=\"\" width=\"489\" height=\"100\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/viewChildError.jpg 489w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/viewChildError-300x61.jpg 300w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/a><\/p>\n<p>@ContentChild in card.component.ts:<\/p>\n<p><a href=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/ErrorcontentChild.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2005\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/ErrorcontentChild.jpg\" alt=\"\" width=\"591\" height=\"137\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/ErrorcontentChild.jpg 591w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/ErrorcontentChild-300x70.jpg 300w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/a><\/p>\n<p>The solution comes with the timing of the component initialization. Lets dig into this and find out.<\/p>\n<h3>Adding the static property.<\/h3>\n<p>The reason for this error is fast and simple to detect, if you know what has changed in Angular 8. The missing argument is the newly introduced static-property. It is a boolean, that determines the timing of component initialization.<\/p>\n<h4>&lt;=Angular 7:<\/h4>\n<p>As you may know (<a href=\"https:\/\/blog.angular-university.io\/angular-viewchild\/\">See: On Init Life Cycle Hook<\/a>) in most cases the @ViewChild\/@ContentChild gets initialized after the main component initialization. So it is more safe to put the component initialization code that uses the references in the <code>ngAfterViewInit<\/code> Lyfecycle Method (for @ContentChild -&gt; <code>ngAfterContentInit<\/code>).<\/p>\n<p>So without the static argument, the decision when to resolve the query was made by the compiler. Each case was examined an decided individually. The @ViewChild\/@ContentChild queries got bundled in two categories. <strong>Static<\/strong> and <strong>dynamic<\/strong>. Following this categorization, the querie results were made available at different times:<\/p>\n<ul>\n<li><strong><strong>Static queries: <\/strong><\/strong>Result of the query is determined statically and does not depend on runtime values. Query results of this kind are available before Change Detection and are accessible in <code>ngOnInit<\/code>.<\/li>\n<li><strong><strong>Dynamic queries: <\/strong><\/strong>The results of dynamicly labelled query results depend on runtime values like bindings. So they are not available after change detection. So they are accessible in <code>ngAfterViewInit<\/code> or <code>ngAfterContentInit.<\/code><\/li>\n<\/ul>\n<h4>&gt;=Angular 8<\/h4>\n<p>Now it is possible (and necessary) to define the timing of initialization proactively. Here it is, where the static property gets relevant. If you set static <strong>false<\/strong>, the component ALWAYS gets initialized after the view initialization in time for the <code>ngAfterViewInit<\/code>\/<code>ngAfterContentInit<\/code>callback functions. This is the matching with the standard case of the old configuration, except that it is now forced. If static is set <strong>true<\/strong>, the initialization will take place at the view initialization (<code>ngOnInit<\/code>for @ViewChild and @ContentChild).<\/p>\n<p>Important: this new flag only applies to @ViewChild and @ContentChild detectors. @ViewChildren and @ContentChildren don&#8217;t work with the concept of static and dynamic. In this case the query is always dynamic.<\/p>\n<p>So now lets try it! We work with both options. As you can see in the following code snippets we add the argument <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code>\u00a0into the decorators. Additionally we include some console logs, to showcase the behaviour for the different options.<\/p>\n<pre class=\"lang:js range:32-35 decode:true \" title=\"card.component.ts\" data-url=\"card.component.ts\">export class CardComponent {\r\n  @ContentChild(CardHeaderDirective,  { static: false }) header?: CardHeaderDirective;\r\n  @ContentChild(CardBodyDirective,  { static: false }) body?: CardBodyDirective;\r\n  @ContentChild(CardFooterDirective,  { static: false }) footer?: CardFooterDirective;\r\n\r\n  constructor() { }\r\n}\r\n<\/pre>\n<pre class=\"lang:js range:1-24 decode:true \" title=\"app.component.ts\" data-url=\"app.component.ts\">import {AfterContentInit, AfterViewInit, Component, ContentChild, OnInit, ViewChild} from '@angular\/core';\r\nimport {CardBodyDirective, CardComponent, CardFooterDirective, CardHeaderDirective} from \".\/card\/card.component\";\r\n\r\n@Component({\r\n  selector: 'my-app',\r\n  templateUrl: '.\/app.component.html',\r\n  styleUrls: [ '.\/app.component.css' ]\r\n})\r\nexport class AppComponent implements OnInit,AfterViewInit{\r\n  @ViewChild(CardComponent, { static: false })card: CardComponent;\r\n\r\n  name = 'Angular';\r\n\r\n  ngOnInit(): void {\r\n    console.log(\"Card Component is:\", this.card)\r\n  }\r\n\r\n  ngAfterViewInit(): void {\r\n    console.log(\"Card Component is: \", this.card)\r\n\r\n  }\r\n}<\/pre>\n<p>If you now run the code with both options: <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code> and <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: true}<\/code> the console will show you results shown in the following matrix. With <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: true}<\/code> the components are already initialized at <code>ngOnInit<\/code>. In the case of <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code> we see that the initialization didn&#8217;t happen until the <code>ngAfterViewInit<\/code>\/<code>ngAfterContentInit<\/code> event.<a href=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2003 size-full\" src=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole-e1565706469494.jpg\" alt=\"\" width=\"1280\" height=\"720\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole-e1565706469494.jpg 1280w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole-e1565706469494-300x169.jpg 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole-e1565706469494-768x432.jpg 768w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/Matrix-Konsole-e1565706469494-1024x576.jpg 1024w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><\/p>\n<h3>What is the best Strategy?<\/h3>\n<p>You now wonder what you are supposed to do with this new superpower? Here are some ideas:<\/p>\n<ol>\n<li>If you are used to work with <code>ngAfterViewInit<\/code>\/ <code>ngAfterContentInit<\/code>anyways, you will be happy with { static: false }.<\/li>\n<li>The feature was included to be able to embed views on the go. In case you need to access TemplateRef in a query for dynamic view creation, you can&#8217;t do this in <code>ngAfterViewInit<\/code>. You will get an ExpressionHasChangedAfterChecked error, as change detection has already run. This is a case where you should set <code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: true}<\/code> and create the view in <code>ngOnInit<\/code>.<\/li>\n<li>If you are a library author, you should get familiar with the inner workings of the static property. The early adoption of the migration will facilitate your users to work with the Ivy Renderer in Angular 9 (aproximatly coming beginning Q4 2019).<\/li>\n<li>In Angular version 9 and later, it will be safe to remove any\u00a0<code>{<a class=\"code-anchor\" href=\"https:\/\/angular.io\/api\/upgrade\/static\">static<\/a>: false}<\/code>\u00a0flags and we will do this cleanup for you in a schematic.<\/li>\n<li>We found a nice quote of Destreyf in the <a href=\"https:\/\/github.com\/akveo\/nebular\/issues\/1514\">Github forum<\/a> to make the decision simpler:<br \/>\n&#8220;more specifically if the element needs to be available during <code>ngOnInit<\/code>, then static needs to be true, but if it can wait until after the init it can be false, which means it won&#8217;t be available until\u00a0<code>ngAfterViewInit<\/code>.&#8221;<\/li>\n<\/ol>\n<p>As often in life it depends on what you want to achieve.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some of you might have stumbled upon an unexpected error message, while updating your project from ng7 to ng8. We all know that. Everything runs smoothly and we use the last 10 minutes before heading off for the update. Not a major issue. Already having packed your stuff and ready to head home, you get [&#8230;]<br \/><a class=\"meta-big\" href=\"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/\"> READ MORE<\/a><\/p>\n","protected":false},"author":23,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,2,98,60],"tags":[112,107,108,106,61,26,109,110,111,75,105],"class_list":["post-1994","post","type-post","status-publish","format-standard","hentry","category-angular","category-javascript","category-node-js","category-typescript","tag-angular","tag-angular-8","tag-angular-9","tag-contentchild","tag-javascript","tag-migration","tag-ng8","tag-ng9","tag-static-property","tag-typescript","tag-viewchild"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Angular ViewChild - static property in ng8 - Web Development Blog<\/title>\n<meta name=\"description\" content=\"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular ViewChild - static property in ng8 - Web Development Blog\" \/>\n<meta property=\"og:description\" content=\"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development tips and tricks - theCodeCampus Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-15T08:57:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-20T18:57:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg\" \/>\n<meta name=\"author\" content=\"Janik Kessler\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Janik Kessler\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/\"},\"author\":{\"name\":\"Janik Kessler\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/0dda62aeb98f2e9a89c2438b6f990101\"},\"headline\":\"Angular ViewChild &#8211; static property in ng8\",\"datePublished\":\"2019-08-15T08:57:11+00:00\",\"dateModified\":\"2023-12-20T18:57:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/\"},\"wordCount\":953,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/VieewChild.jpg\",\"keywords\":[\"Angular\",\"Angular 8\",\"Angular 9\",\"contentChild\",\"JavaScript\",\"Migration\",\"ng8\",\"ng9\",\"static property\",\"TypeScript\",\"viewChild\"],\"articleSection\":[\"Angular\",\"JavaScript\",\"Node.js\",\"TypeScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/\",\"name\":\"Angular ViewChild - static property in ng8 - Web Development Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/VieewChild.jpg\",\"datePublished\":\"2019-08-15T08:57:11+00:00\",\"dateModified\":\"2023-12-20T18:57:44+00:00\",\"description\":\"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/VieewChild.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/VieewChild.jpg\",\"width\":753,\"height\":134},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-viewchild-static-property-in-ng8\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular ViewChild &#8211; static property in ng8\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"name\":\"Web Development tips and tricks - theCodeCampus Blog\",\"description\":\"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\",\"name\":\"theCodeCampus\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"width\":156,\"height\":156,\"caption\":\"theCodeCampus\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/0dda62aeb98f2e9a89c2438b6f990101\",\"name\":\"Janik Kessler\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/janik-kessler-tcc-author-96x96.png\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/janik-kessler-tcc-author-96x96.png\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/janik-kessler-tcc-author-96x96.png\",\"caption\":\"Janik Kessler\"},\"description\":\"Hi, I'm Janik. I'm a web development enthusiast and love to share my experiences. As a software trainer and engineer, I always seek to exchange ideas with other developers. I've been part of the theCodeCampus team since 2019 and have had the opportunity to meet many exciting engineers, learning a great deal from their experiences.\",\"sameAs\":[\"https:\\\/\\\/thecodecampus.de\\\/ueber-uns\\\/trainer\\\/janik-kessler\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/janik-kessler-615034233\\\/\"],\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/author\\\/jhorst\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular ViewChild - static property in ng8 - Web Development Blog","description":"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/","og_locale":"en_US","og_type":"article","og_title":"Angular ViewChild - static property in ng8 - Web Development Blog","og_description":"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!","og_url":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/","og_site_name":"Web Development tips and tricks - theCodeCampus Blog","article_published_time":"2019-08-15T08:57:11+00:00","article_modified_time":"2023-12-20T18:57:44+00:00","og_image":[{"url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg","type":"","width":"","height":""}],"author":"Janik Kessler","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Janik Kessler","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#article","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/"},"author":{"name":"Janik Kessler","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/0dda62aeb98f2e9a89c2438b6f990101"},"headline":"Angular ViewChild &#8211; static property in ng8","datePublished":"2019-08-15T08:57:11+00:00","dateModified":"2023-12-20T18:57:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/"},"wordCount":953,"commentCount":3,"publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#primaryimage"},"thumbnailUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg","keywords":["Angular","Angular 8","Angular 9","contentChild","JavaScript","Migration","ng8","ng9","static property","TypeScript","viewChild"],"articleSection":["Angular","JavaScript","Node.js","TypeScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/","url":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/","name":"Angular ViewChild - static property in ng8 - Web Development Blog","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#primaryimage"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#primaryimage"},"thumbnailUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg","datePublished":"2019-08-15T08:57:11+00:00","dateModified":"2023-12-20T18:57:44+00:00","description":"Elevate Angular 8 expertise! Master ViewChild static property. Enhance component interaction seamlessly. Supercharge your Angular development now!","breadcrumb":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#primaryimage","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2019\/08\/VieewChild.jpg","width":753,"height":134},{"@type":"BreadcrumbList","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-viewchild-static-property-in-ng8\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.thecodecampus.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Angular ViewChild &#8211; static property in ng8"}]},{"@type":"WebSite","@id":"https:\/\/www.thecodecampus.de\/blog\/#website","url":"https:\/\/www.thecodecampus.de\/blog\/","name":"Web Development tips and tricks - theCodeCampus Blog","description":"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.","publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.thecodecampus.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.thecodecampus.de\/blog\/#organization","name":"theCodeCampus","url":"https:\/\/www.thecodecampus.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","width":156,"height":156,"caption":"theCodeCampus"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/0dda62aeb98f2e9a89c2438b6f990101","name":"Janik Kessler","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/09\/janik-kessler-tcc-author-96x96.png","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/09\/janik-kessler-tcc-author-96x96.png","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/09\/janik-kessler-tcc-author-96x96.png","caption":"Janik Kessler"},"description":"Hi, I'm Janik. I'm a web development enthusiast and love to share my experiences. As a software trainer and engineer, I always seek to exchange ideas with other developers. I've been part of the theCodeCampus team since 2019 and have had the opportunity to meet many exciting engineers, learning a great deal from their experiences.","sameAs":["https:\/\/thecodecampus.de\/ueber-uns\/trainer\/janik-kessler","https:\/\/www.linkedin.com\/in\/janik-kessler-615034233\/"],"url":"https:\/\/www.thecodecampus.de\/blog\/author\/jhorst\/"}]}},"_links":{"self":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/comments?post=1994"}],"version-history":[{"count":37,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1994\/revisions"}],"predecessor-version":[{"id":2591,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1994\/revisions\/2591"}],"wp:attachment":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/media?parent=1994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/categories?post=1994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/tags?post=1994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}