﻿
{"id":13330,"date":"2020-02-16T12:38:04","date_gmt":"2020-02-16T12:38:04","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=13330"},"modified":"2020-02-16T12:38:04","modified_gmt":"2020-02-16T12:38:04","slug":"angularda-input-ve-output-degiskenler-ile-componentler-arasi-iletisim","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/angularda-input-ve-output-degiskenler-ile-componentler-arasi-iletisim\/","title":{"rendered":"Angular&#8217;da @Input ve @Output De\u011fi\u015fkenler \u0130le Componentler Aras\u0131 \u0130leti\u015fim"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>G\u00fcn\u00fcm\u00fcz UI mimarilerinin bir\u00e7o\u011fu, birbirlerinden ba\u011f\u0131ms\u0131z olacak \u015fekilde geli\u015ftirilen bile\u015fen(component) yap\u0131lanmalar\u0131n\u0131n bir araya gelmesi neticesinde b\u00fct\u00fcn\u00fcn olu\u015fturulmas\u0131 ve b\u00f6ylece uygulaman\u0131n y\u00f6netilebilir ve \u00f6l\u00e7eklendirilebilir par\u00e7alardan meydana getirilmesi mant\u0131\u011f\u0131na dayal\u0131 bir yakla\u015f\u0131m benimsemektedirler. Haliyle bu yakla\u015f\u0131m\u0131n bayraktarl\u0131\u011f\u0131n\u0131 yapan ve bir\u00e7ok mimari yahut k\u00fct\u00fcphaneye bu konuda \u00f6n ayak olan Angular mimarisinde, b\u00fct\u00fcn\u00fcn par\u00e7alar\u0131 olan componentlerde <em><strong>@Input<\/strong><\/em> ve <em><strong>@Output<\/strong><\/em> de\u011fi\u015fkenlerinin nas\u0131l bir rol ald\u0131klar\u0131n\u0131 ve componentler aras\u0131 ileti\u015fimi nas\u0131l sa\u011flad\u0131klar\u0131n\u0131 inceleyece\u011fiz.<\/p>\n<p>\u0130lk olarak kavramsal de\u011ferlendirmeyi anla\u015f\u0131l\u0131r k\u0131labilmek i\u00e7in \u00f6ncelikle componentler aras\u0131 ili\u015fkilendirmeyi ele alarak netle\u015ftirmek gerekmektedir. Bunun i\u00e7in bir Angular uygulamas\u0131 olu\u015fturunuz ve ard\u0131ndan i\u00e7erisine &#8220;A&#8221; ve &#8220;B&#8221; olmak \u00fczere iki adet component ekleyiniz. Ard\u0131ndan &#8220;A&#8221; componentinin g\u00f6r\u00fcnt\u00fcs\u00fcnde &#8220;B&#8221; componentini referans ediniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim.png\" alt=\"Angular&#039;da @Input ve @Output De\u011fi\u015fkenler \u0130le Componentler Aras\u0131 \u0130leti\u015fim\" width=\"258\" height=\"100\" class=\"aligncenter size-full wp-image-13349\" \/><\/a><\/p>\n<p>\u0130\u015fte bu ili\u015fki neticesinde terminoloji devreye girmekte ve &#8220;A&#8221; componentine &#8220;Parent Component&#8221;, &#8220;B&#8221; componentine ise &#8220;Child Component&#8221; denmektedir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim.jpg\" alt=\"Angular&#039;da @Input ve @Output De\u011fi\u015fkenler \u0130le Componentler Aras\u0131 \u0130leti\u015fim\" width=\"1280\" height=\"720\" class=\"aligncenter size-full wp-image-13345\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim.jpg 1280w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-300x169.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-1024x576.jpg 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-768x432.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><\/p>\n<p>Bu bilgiler e\u015fli\u011finde art\u0131k @Input ve @Output de\u011fi\u015fkenleri a\u00e7\u0131klayabiliriz.<\/p>\n<table>\n<thead>\n<tr>\n<th>@Input<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Parent componentten(A) Child componente(B) veri g\u00f6ndermek i\u00e7in kullan\u0131lan de\u011fi\u015fkendir.<\/td>\n<\/tr>\n<tr>\n<td>\n&#8216;b.component.ts&#8217; i\u00e7eri\u011fi;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { Component, OnInit, Input } from '@angular\/core';\r\n@Component({\r\n  selector: 'app-b',\r\n  templateUrl: '.\/b.component.html',\r\n  styleUrls: &#x5B;'.\/b.component.css']\r\n})\r\nexport class BComponent implements OnInit {\r\n  constructor() { }\r\n  @Input() data: string;\r\n  ngOnInit(): void {\r\n    console.log(`A'dan B'ye '${this.data}' de\u011feri g\u00f6nderilmi\u015ftir.`);\r\n  }\r\n}\r\n<\/pre>\n<p>&#8216;a.component.ts&#8217; i\u00e7eri\u011fi;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;app-b data=&quot;Merhaba&quot;&gt;&lt;\/app-b&gt;\r\n<\/pre>\n<p>Burada g\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere &#8220;B&#8221; componenti i\u00e7erisindeki @Input data de\u011fi\u015fkenine attribute k\u0131vam\u0131nda eri\u015febilmekte ve istedi\u011fimiz de\u011feri g\u00f6nderebilmekteyiz.<\/p>\n<p>\u00c7\u0131kt\u0131 olarak;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-2.png\" alt=\"Angular&#039;da @Input ve @Output De\u011fi\u015fkenler \u0130le Componentler Aras\u0131 \u0130leti\u015fim\" width=\"311\" height=\"76\" class=\"aligncenter size-full wp-image-13362\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-2.png 311w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-2-300x73.png 300w\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" \/><\/a>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>@Output<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Child componentten(B) Parent componente(A) veri g\u00f6ndermek i\u00e7in kullan\u0131lan de\u011fi\u015fkendir.<\/td>\n<\/tr>\n<tr>\n<td>\n&#8216;b.component.ts&#8217; i\u00e7eri\u011fi;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { Component, OnInit, Input, Output, EventEmitter } from '@angular\/core';\r\n@Component({\r\n  selector: 'app-b',\r\n  templateUrl: '.\/b.component.html',\r\n  styleUrls: &#x5B;'.\/b.component.css']\r\n})\r\nexport class BComponent implements OnInit {\r\n  constructor() { }\r\n  @Output() myevent: EventEmitter&lt;any&gt; = new EventEmitter();\r\n  ngOnInit(): void {\r\n    this.myevent.emit({ message: &quot;Merhaba&quot; });\r\n  }\r\n}\r\n<\/pre>\n<p>&#8216;a.component.html&#8217; i\u00e7eri\u011fi;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;app-b (myevent)=&quot;click($event)&quot;&gt;&lt;\/app-b&gt;\r\n<\/pre>\n<p>Burada da dikkat edilirse &#8216;b.component.ts&#8217; i\u00e7erisinde tan\u0131mlanan @Output t\u00fcr\u00fcndeki &#8220;myevent&#8221; de\u011fi\u015fkeni &#8220;A&#8221; g\u00f6r\u00fcnt\u00fcs\u00fc i\u00e7erisindeki referans\u0131nda event olarak kullan\u0131labilmekte ve ta\u015f\u0131d\u0131\u011f\u0131 de\u011feride &#8216;$event&#8217; parametresiyle yakalayabilmektedir.<\/p>\n<p>&#8216;a.component.ts&#8217; i\u00e7eri\u011fi;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { Component, OnInit } from '@angular\/core';\r\n\r\n@Component({\r\n  selector: 'app-a',\r\n  templateUrl: '.\/a.component.html',\r\n  styleUrls: &#x5B;'.\/a.component.css']\r\n})\r\nexport class AComponent implements OnInit {\r\n  constructor() { }\r\n  ngOnInit(): void { }\r\n\r\n  click(data) {\r\n    console.log(`B'den A'ya ${data.message} nesnesi g\u00f6nderilmi\u015ftir.`);\r\n  }\r\n}\r\n<\/pre>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-3.png\" alt=\"Angular&#039;da @Input ve @Output De\u011fi\u015fkenler \u0130le Componentler Aras\u0131 \u0130leti\u015fim\" width=\"306\" height=\"72\" class=\"aligncenter size-full wp-image-13367\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-3.png 306w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-3-300x71.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/a>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>@Input ve @Output yap\u0131lanmas\u0131n\u0131n yukar\u0131da pratik olarak ele ald\u0131\u011f\u0131m\u0131z \u00e7al\u0131\u015fma mant\u0131\u011f\u0131n\u0131 a\u015fa\u011f\u0131daki g\u00f6rselde daha da somutla\u015ft\u0131rarak inceleyebilirsiniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/02\/Angularda-@Input-ve-@Output-De\u011fi\u015fkenler-\u0130le-Componentler-Aras\u0131-\u0130leti\u015fim-1.png\" alt=\"\" width=\"300\" height=\"172\" class=\"aligncenter size-full wp-image-13361\" \/><\/a><\/p>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, G\u00fcn\u00fcm\u00fcz UI mimarilerinin bir\u00e7o\u011fu, birbirlerinden ba\u011f\u0131ms\u0131z olacak \u015fekilde geli\u015ftirilen bile\u015fen(component) yap\u0131lanmalar\u0131n\u0131n bir araya gelmesi neticesinde b\u00fct\u00fcn\u00fcn olu\u015fturulmas\u0131 ve b\u00f6ylece uygulaman\u0131n y\u00f6netilebilir ve \u00f6l\u00e7eklendirilebilir par\u00e7alardan meydana getirilmesi mant\u0131\u011f\u0131na dayal\u0131 bir yakla\u015f\u0131m benimsemektedirler. Haliyle bu&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":13345,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2420,2144,2415,2599,2756,3018,3155],"tags":[2156,3152,3151,3149,3150,3154,3153],"class_list":["post-13330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular","category-angular-4","category-angular-5","category-angular-6","category-angular-7","category-angular-8","category-angular-9","tag-angular","tag-angular-9","tag-angular-componentler-arasi-iletisim","tag-angularda-input-degiskenler","tag-angularda-output-degiskenler","tag-child-component","tag-parent-component"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/13330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=13330"}],"version-history":[{"count":33,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/13330\/revisions"}],"predecessor-version":[{"id":13369,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/13330\/revisions\/13369"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/13345"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=13330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=13330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=13330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}