{"id":59704,"date":"2018-05-02T17:17:48","date_gmt":"2018-05-02T11:47:48","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=59704"},"modified":"2024-04-12T14:20:45","modified_gmt":"2024-04-12T08:50:45","slug":"angular-component-interaction","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/","title":{"rendered":"Angular Component Interaction"},"content":{"rendered":"<h1>Angular Components Interaction<\/h1>\n<p>Angular Components are a logical piece of code for Angular JS application. Angular Components consists of the following \u2212<\/p>\n<p>Template \u2212 This is used to render the view for the application. This contains the HTML that needs to be rendered in the application. This part also includes the binding and directives.<\/p>\n<p>Class \u2212 This is like a class defined in any language such as C. This contains properties and methods. This has the code which is used to support the view. It is defined in TypeScript.<\/p>\n<p>Metadata \u2212 This has the extra data defined for the Angular class. It is defined with a decorator.<\/p>\n<p>Common component communication scenarios are listed, in which two or more components share information.<\/p>\n<p>Pass data from parent to child with input binding<\/p>\n<p>HeroChildComponent has two input properties, typically adorned with @Input decorations.<\/p>\n<p>&nbsp;<\/p>\n<p>component-interaction\/src\/app\/hero-child.component.ts<\/p>\n<p>import { Component, Input } from &#8216;@angular\/core&#8217;;<\/p>\n<p>import { Hero } from &#8216;.\/hero&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>@Component({<\/p>\n<p>selector: &#8216;hero-child&#8217;,<\/p>\n<p>template: `<\/p>\n<p>&lt;h3&gt;{{hero.name}} says:&lt;\/h3&gt;<\/p>\n<p>&lt;p&gt;I, {{hero.name}}, am at your service, {{masterName}}.&lt;\/p&gt;<\/p>\n<p>`<\/p>\n<p>})<\/p>\n<p>export class HeroChildComponent {<\/p>\n<p>@Input() hero: Hero;<\/p>\n<p>@Input(&#8216;master&#8217;) masterName: string;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>The second @Input aliases the child component property name masterName as &#8216;master&#8217;.<\/p>\n<p>The HeroParentComponent nests the child HeroChildComponent inside an *ngFor repeater, binding its master string property to the child&#8217;s master alias, and each iteration&#8217;s hero instance to the child&#8217;s hero property.<\/p>\n<p>&nbsp;<\/p>\n<p><u>component-interaction\/src\/app\/hero-parent.component.ts<\/u><\/p>\n<p>import { Component } from &#8216;@angular\/core&#8217;;<\/p>\n<p>import { HEROES } from &#8216;.\/hero&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>@Component({<\/p>\n<p>selector: &#8216;hero-parent&#8217;,<\/p>\n<p>template: `<\/p>\n<p>&lt;h2&gt;{{master}} controls {{heroes.length}} heroes&lt;\/h2&gt;<\/p>\n<p>&lt;hero-child *ngFor=&#8221;let hero of heroes&#8221;<\/p>\n[hero]=&#8221;hero&#8221;<\/p>\n[master]=&#8221;master&#8221;&gt;<\/p>\n<p>&lt;\/hero-child&gt;<\/p>\n<p>`<\/p>\n<p>})<\/p>\n<p>export class HeroParentComponent {<\/p>\n<p>heroes = HEROES;<\/p>\n<p>master = &#8216;Master&#8217;;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>E2E test that all children were instantiated and displayed as expected:<\/p>\n<p>&nbsp;<\/p>\n<p><u>component-interaction\/e2e-spec.ts<\/u><\/p>\n<p>\/\/ &#8230;<\/p>\n<p>let _heroNames = [&#8216;Mr. IQ&#8217;, &#8216;Magneta&#8217;, &#8216;Bombasto&#8217;];<\/p>\n<p>let _masterName = &#8216;Master&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>it(&#8216;should pass properties to children properly&#8217;, function () {<\/p>\n<p>let parent = element.all(by.tagName(&#8216;hero-parent&#8217;)).get(0);<\/p>\n<p>let heroes = parent.all(by.tagName(&#8216;hero-child&#8217;));<\/p>\n<p>&nbsp;<\/p>\n<p>for (let i = 0; i &lt; _heroNames.length; i++) {<\/p>\n<p>let childTitle = heroes.get(i).element(by.tagName(&#8216;h3&#8217;)).getText();<\/p>\n<p>let childDetail = heroes.get(i).element(by.tagName(&#8216;p&#8217;)).getText();<\/p>\n<p>expect(childTitle).toEqual(_heroNames[i] + &#8216; says:&#8217;);<\/p>\n<p>expect(childDetail).toContain(_masterName);<\/p>\n<p>}<\/p>\n<p>});<\/p>\n<p>\/\/ &#8230;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"VSKILLbodytext\"><strong>IT Professionals, Web Developers, Web Programmers, IT students can Apply for the certification course to move ahead in their careers.<\/strong><\/p>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/web-development\/angular-4-certification\" rel=\"attachment wp-att-61497\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-61497\" src=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\" sizes=\"auto, (max-width: 1050px) 100vw, 1050px\" srcset=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png 1050w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-300x48.png 300w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-768x124.png 768w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-1024x165.png 1024w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4-712x115.png 712w\" alt=\"\" width=\"1050\" height=\"169\" \/><\/a><\/p>\n<ul>\n<li class=\"VSKILLbodytext\"><a href=\"https:\/\/www.vskills.in\/practice\/skills\/Web-Development\/Angular-4\" target=\"_blank\" rel=\"noopener\">Practice Test for Angular4 <\/a><\/li>\n<li class=\"VSKILLbodytext\"><a href=\"https:\/\/www.vskills.in\/certification\/web-development\/angular-4-certification\" target=\"_blank\" rel=\"noopener\">Govt Certification in Angular 4<\/a><\/li>\n<li><a href=\"https:\/\/www.vskills.in\/certification\/blog\/\">Blog posts on Angular 4 and Web Development<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/web-development\/angular-4\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-55483 size-full\" src=\"http:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/05\/Back-Arrow.jpg\" alt=\"Angular 4 Tutorial Index\" width=\"47\" height=\"52\" \/>Back to Angular 4 Tutorial Main Page <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angular Components Interaction Angular Components are a logical piece of code for Angular JS application. Angular Components consists of the following \u2212 Template \u2212 This is used to render the view for the application. This contains the HTML that needs to be rendered in the application. This part also includes the binding and directives. Class&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[7230,7231,5743],"tags":[7221,7227,7235,7236,7263,7305,7306,7226,7234,7232,7223,7233],"class_list":["post-59704","page","type-page","status-publish","hentry","category-angular-2","category-angular-4","category-web-development","tag-angular","tag-angular-4","tag-angular-4-tutorial","tag-angular-cli","tag-angular-component","tag-angular-component-interaction","tag-angular-interaction","tag-angular-js","tag-angular-js-tutorial","tag-angular-tutorial","tag-angularjs","tag-angularjs-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Angular Component Interaction - Tutorial<\/title>\n<meta name=\"description\" content=\"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.\" \/>\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.vskills.in\/certification\/tutorial\/angular-component-interaction\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular Component Interaction - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:50:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/\",\"name\":\"Angular Component Interaction - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"datePublished\":\"2018-05-02T11:47:48+00:00\",\"dateModified\":\"2024-04-12T08:50:45+00:00\",\"description\":\"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png\",\"width\":1050,\"height\":169},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular Component Interaction\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular Component Interaction - Tutorial","description":"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.","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.vskills.in\/certification\/tutorial\/angular-component-interaction\/","og_locale":"en_US","og_type":"article","og_title":"Angular Component Interaction - Tutorial","og_description":"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:50:45+00:00","og_image":[{"url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/","name":"Angular Component Interaction - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","datePublished":"2018-05-02T11:47:48+00:00","dateModified":"2024-04-12T08:50:45+00:00","description":"Angular Components Interaction: Angular Components are a logical piece of code for Angular JS application. Click here for more.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#primaryimage","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2018\/04\/Angular-4.png","width":1050,"height":169},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/angular-component-interaction\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Angular Component Interaction"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=59704"}],"version-history":[{"count":6,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59704\/revisions"}],"predecessor-version":[{"id":64212,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/59704\/revisions\/64212"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=59704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=59704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=59704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}