<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>index.html &#8211; The SIGMA</title>
	<atom:link href="https://danushka96.github.io/sigma/index.php/tag/index-html/feed/" rel="self" type="application/rss+xml" />
	<link>https://danushka96.github.io/sigma/</link>
	<description>&#60;For Those Who Code/&#62;</description>
	<lastBuildDate>
	Sat, 02 Mar 2019 16:57:34 +0000	</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1.1</generator>
	<item>
		<title>Components in Angular</title>
		<link>https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/#respond</comments>
				<pubDate>Thu, 24 Jan 2019 16:25:24 +0000</pubDate>
		<dc:creator><![CDATA[Gayan Sampath]]></dc:creator>
				<category><![CDATA[angular.js]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[attibute]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[decorator]]></category>
		<category><![CDATA[index.html]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[root component]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[typescript]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=1700</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">5</span> <span class="rt-label rt-postfix">minutes</span></span> කොහොමද යාලුවනේ! ඔන්න මං අදත් ආවා Angular පාඩම් මාලාවේ තුන්නවෙනි පාඩමත් සමගින්.කලින් පාඩමේදී අපි කතා කලා Angular වල folder structure එක සහ index page එක render වුන විදිය ගැන. අද පාඩමේදී අපි කතා කරන්ට බලාපොරොත්තු වෙන්නේ Angular වල components ගැන.ගොඩක් දේවල් කතා කරන්න තියන නිසා කෙලින්ම පාඩමට බහිමු. Angular වල<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/">Components in Angular</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">5</span> <span class="rt-label rt-postfix">minutes</span></span>
<p>කොහොමද යාලුවනේ! ඔන්න මං අදත් ආවා Angular පාඩම් මාලාවේ තුන්නවෙනි පාඩමත් සමගින්.<a href="https://danushka96.github.io/sigma/index.php/2019/01/19/angular-7-step2/">කලින් පාඩමේදී</a> අපි කතා කලා Angular වල folder structure එක සහ index page එක render වුන විදිය ගැන. අද පාඩමේදී අපි කතා කරන්ට බලාපොරොත්තු වෙන්නේ Angular වල components ගැන.ගොඩක් දේවල් කතා කරන්න තියන නිසා කෙලින්ම පාඩමට බහිමු.</p>



<p>Angular වල component එකක් හැදිලා තියෙන්නේ Template , class හා metadata කියන කොටස් තුනේ එකතුවෙන්.view එකට අදාලව තියන HTML code ඔක්කොම වගේ අයිති වෙන්නේ මෙන්න මේ Template කියන කොටසට…component එකේ properties , methods හා view එකට අදාලව තියන logic තියාගන්නේ component class එක ඇතුලේ..metadata කියන කොටසේ තමයි තියෙන්නේ component එක අපේ app එකට සම්බන්ධ(attach)  කිරීමට අදාල විස්තර…Metadata define කරලා තියෙන්නේ Decorator කියලා එකකින්.Decorator එකක් කියන්නේ අපේ component එක app එකට සම්බන්ධ කිරීමට අදාල විස්තර සපයන විශේෂ function  එකක්.component එකක ප්‍රධාන කොටස් තුන ගැන සරලව ඔය ටික තමයි කියන්න තියෙන්නේ…දැන් අපි එකින් එක ගැන තව පොඩ්ඩක් කතා කරලා බලමු.</p>



<p>මුලින්ම අපි අලුත් component එකක් හදාගමු. ඔයාලගේ terminal එකේ අපි කලින් හදා ගත්ත angular project එක ඇතුලට ගිහින්<code>ng g c&nbsp;&lt;component_name&gt;</code>  කියන command එක දුන්නාම අලුත් component එකක් හදා ගන්න පුලවන්.ඔන්න ඔය විදියට component එකක් හදා ගත්තාම ඔයාලට පේනවා file 4 ක් තියන folder එකක් තමයි component එකක් විදියට හැදිලා එන්නේ.අන්න ඒ file 4 ගැන සලකා බැලුවොත් , typescript (.ts ) file එකේ තමයි component එකේ class එකයි metadata යි තියා ගන්නේ.html file එකේ තමයි component එකේ view එක තියෙන්නේ. component  එකකට අදාල styles තියාගන්නේ මෙන්න මේ .css කියන css file එක ඇතුලේ..අනික් file එක(.spec.ts) නම් පාවිච්චි කරන්නේ testing වලට.</p>



<p>ඔයාලට මතකද දන්නේ නෑ මං කලින් පාඩමේදී පාවිච්චි කලා root component කියලා වචනයක්..ඒ වෙලාවෙදි ඒක ගැන කතා කලේ නැති වුනාට දැන් අපි ඒ ගැන පොඩ්ඩක් කතා කරලා බලමු.root component එක තමයි අපේ app එකේ තියන ප්‍රධානම component එක.අපි අලුතින් හදන component දාන්නේ මෙන්න මේ root component එක ඇතුලට.මුලින්ම අපිට index page එක render වෙද්දි පෙනුනේ මෙන්න මේ root component එකේ elements තමයි.මුලින්ම අපි root component එකේ typescript file එකට ගිහින් බලමු.</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-4.jpg" alt="" data-id="1702" data-link="https://danushka96.github.io/sigma/?attachment_id=1702" class="wp-image-1702" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-4.jpg 821w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-4-300x99.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-4-768x253.jpg 768w" sizes="(max-width: 821px) 100vw, 821px" /></figure></li></ul>



<p>ඔන්න ඔහොම තමයි root component එකට අදාල typescript file එක( app.component.ts file ) තියෙන්නේ. මෙහි මුලින්ම තියනවා Metadata..</p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip.png" alt="" class="wp-image-1703" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip.png 821w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-300x99.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-768x253.png 768w" sizes="(max-width: 821px) 100vw, 821px" /></figure>



<p>Metadata ගැන බැලුවොත්, මුලින්ම තියන selector එක , component එක html file එකට attach කරන විට  custom html tag එකක් විදියට වැඩ කරනවා &#8230;අපි open කරලා තියෙන්නේ root component එකට අදාල typescript file එක නිසා එහි selector එක නම් කරලා තියනවා app-root කියලා..දැන් ඔයාලට index.html file එක ඇතුලට ගියොත් බලාගන්න පුලුවන් app-root කියලා custom html tag එකක් තියනවා</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-1.png" alt="" data-id="1704" data-link="https://danushka96.github.io/sigma/?attachment_id=1704" class="wp-image-1704" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-1.png 852w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-1-300x130.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-1-768x334.png 768w" sizes="(max-width: 852px) 100vw, 852px" /></figure></li></ul>



<p>ඔන්න ඔය custom html tag එක තියන තැනට තමයි root component එක index page එකට attach කරලා තියෙන්නේ.</p>



<p>component එකක් තවත් component එකකට හරි අදාල html page එකකට හරි attach කරන්න පුලුවන් විදි තුනක් තියනවා..පලමු ක්‍රමය තමයි selector එක custom html tag එකක් විදියට පාවිච්චි කරලා attach කරන්න පුලුවන්..අපි ඉහලින් කතා කලේ අන්න ඒ ක්‍රමය ගැන තමයි..දෙවෙනි ක්‍රමය තමයි selector එක class එකක් විදියට පාවිච්චි කරල attach කරන්නත් පුලුවන්..code එක ගත්තොත් මෙන්න මේ වගේ..</p>



<p><strong><em>app-component.ts</em></strong></p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-2.png" alt="" data-id="1705" data-link="https://danushka96.github.io/sigma/?attachment_id=1705" class="wp-image-1705" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-2.png 793w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-2-300x113.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-2-768x290.png 768w" sizes="(max-width: 793px) 100vw, 793px" /></figure></li></ul>



<p><strong><em>index.html</em></strong></p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-3.png" alt="" data-id="1707" data-link="https://danushka96.github.io/sigma/?attachment_id=1707" class="wp-image-1707" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-3.png 760w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-3-300x158.png 300w" sizes="(max-width: 760px) 100vw, 760px" /></figure></li></ul>



<p>තුන්වෙනි විදිය තමයි selector එක attribute එකක් විදියට පාවිච්චි කරලත් component එක page එකට attach කරන පුලුවන්.ඒකේ code එක ගත්තොත් මෙන්න මේ වගේ..</p>



<p><strong><em>app.component.ts﻿</em></strong></p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-4.png" alt="" class="wp-image-1708" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-4.png 512w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-4-300x154.png 300w" sizes="(max-width: 512px) 100vw, 512px" /></figure>



<p><strong><em>Index.html</em></strong></p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-5.png" alt="" data-id="1709" data-link="https://danushka96.github.io/sigma/?attachment_id=1709" class="wp-image-1709" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-5.png 738w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-5-300x152.png 300w" sizes="(max-width: 738px) 100vw, 738px" /></figure></li></ul>



<p>ඔන්න ඔය ක්‍රම තුනෙන් කැමති විදියක් පාවිච්චි කරලා අලුත් component එකක් html page එකට attach කරන්න පුලුවන්.</p>



<p>Metadata වල ඊලගට තියෙන්නේ templateurl එකයි styleurls එකයි. templateurl එකෙන් තමයි අපේ component එකේ html page එක තියන තැන පෙන්නනේ. component එකේ styles තියන css file එක තියන තැන පෙන්නනේ මෙන්න මේ styleurls එකෙන්.component එකකට අදාල metadata නම් තියෙන්නේ ඔච්චරයි..</p>



<p>typescript file එකේ metadata වලට යටින් තියෙන්නේ component එකේ class එක..component එකේ methods , properties තියාගන්නේ මෙන්න මේ component class එක ඇතුලේ. මුලින් අපි කතා කලානේ root componet එකේ metadata ගැන.දැන් බලමු root componet එකේ class එක ගැන.</p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-6.png" alt="" class="wp-image-1710" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-6.png 665w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-6-300x149.png 300w" sizes="(max-width: 665px) 100vw, 665px" /></figure>



<p>ඉහලදි මම පෙන්නපු විදියට root component එකේ typescript file එක ඔන්න ඔය විදියට තමයි තියෙන්නේ. root component කියලා metadata වලට යටින් තියෙන්නේ component class එක.root component class එක ගත්තොත් ඔයාලට පේනවා ඇති title කියලා property එකක් define කරලා තියනවා..ඔන්න ඔය විදියට අපේ component එකට අවශය properties , methods ඕනි තරමක් define කරන්න පුලුවන් මෙන්න මේ component class එක ඇතුලේ.</p>



<p>component එකක තියන අනෙක් කොටස තමයි view එක .component එකේ view එක පෙන්නනේ මෙන්න මේ html file එකෙන්.root component එකේ view එක බැලුවොත් මෙන්න මේ වගේ view එකක් තමයි තිබුනේ.</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/a-1024x462.jpg" alt="" data-id="1573" data-link="https://danushka96.github.io/sigma/index.php/2019/01/16/angular7/a/" class="wp-image-1573" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/a-1024x462.jpg 1024w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/a-300x135.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/a-768x347.jpg 768w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/a.jpg 1351w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></li></ul>



<p>root component එකට අදාල html file එක බැලුවොත් මෙන්න මේ වගේ.</p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-7.png" alt="" class="wp-image-1711" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-7.png 928w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-7-300x156.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-7-768x399.png 768w" sizes="(max-width: 928px) 100vw, 928px" /></figure>



<p>මුලින්ම තියනවා well come message එක.</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-8.png" alt="" data-id="1712" data-link="https://danushka96.github.io/sigma/?attachment_id=1712" class="wp-image-1712" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-8.png 849w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-8-300x44.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-8-768x112.png 768w" sizes="(max-width: 849px) 100vw, 849px" /></figure></li></ul>



<p>ඔයාලට මතක ඇති root component class එකේ property එකක් තිබුණා title කියලා.අන්න ඒ title property එක තමයි well come massage එක වදියට මෙතනදි display වෙලා තියෙන්නේ.ඔන්න ඔය වඳියට component class එකේ define කරන properties සහ methods අපේ component එකේ view එකට අවශය විදියට display   කරලා පෙන්න පුලුවන්.component ගැන කියන්න තියෙන්නෙනම් ඔච්චරයි. component ගැන තවමත් පොඩි  හෝ අවුලක් තියනවනම්  මෙන්න මේ උදාහරණයත් බලන්නකෝ.</p>



<p>මෙහිදී මම කරන්න යන්නේ අලුතින් component එකක් හදාගෙන ඒක root component එකට attach කරලා display කරන එක.</p>



<p>මුලින්ම මම component එකක් හදා ගන්නම් <em>&#8220;firstComponent&#8221;</em> කියලා.</p>



<p><code>ng g c firstComponent</code></p>



<p>හරි, දැන් ඔයාලට හැදිලා එන්න ඇති file 4 ක් තියන &#8220;firstComponent&#8221; කියලා folder එකක්. මුලින්ම මම හදා ගත්ත අලුත් component එකේ property එකක් define කරනවා &#8220;header&#8221; කියලා. &#8220;header &#8221; එකට value එකක් දෙනවා &#8220;This is my first component &#8221; කියලා.</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-9.png" alt="" data-id="1713" data-link="https://danushka96.github.io/sigma/?attachment_id=1713" class="wp-image-1713" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-9.png 701w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/tempsnip-9-300x151.png 300w" sizes="(max-width: 701px) 100vw, 701px" /></figure></li></ul>



<p>හරි , දැන් ඒ define කරපු property එක මෙන්න මේ විදියට html page එකට set කරමු.</p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-5.jpg" alt="" class="wp-image-1714" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-5.jpg 769w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-5-300x34.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-5-768x86.jpg 768w" sizes="(max-width: 769px) 100vw, 769px" /></figure>



<p>හරි දැන් හදා ගත්ත component එක root component එකට attach කරමු.  අපේ හදා ගත්ත component එක  පැහැදිලිව පෙනෙන්න ඕනි නිසා root component එකේ දැනට තියන elements delete කරලා අපේ අලුත් component එක attach කරමු.හරියට මෙන්න මේ වගේ.</p>



<ul class="wp-block-gallery columns-1 is-cropped"><li class="blocks-gallery-item"><figure><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-6.jpg" alt="" data-id="1715" data-link="https://danushka96.github.io/sigma/?attachment_id=1715" class="wp-image-1715" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-6.jpg 629w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-6-300x73.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></figure></li></ul>



<p>ඔන්න ඔය විදියට අලුත් component එක  attach කලාට පස්සේ මෙන්න මේ වගේ view එකක් ඔයාලට දැක ගන්න පුලුවන්</p>



<figure class="wp-block-image"><img src="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-7.jpg" alt="" class="wp-image-1716" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-7.jpg 494w, https://danushka96.github.io/sigma/wp-content/uploads/2019/01/Capture-7-300x131.jpg 300w" sizes="(max-width: 494px) 100vw, 494px" /></figure>



<p>හරි, components ගැන හොදටම තේරෙන්න ඇති කියලා හිතනවා..තවත් මොකක් හරි අව්ලක් තියනවනම් comment එකක් දාන්න.මීලඟ පාඩමෙන් අපි බලමු Angular වල data binding ගැන.මීලඟ පාඩමෙන් හමුවන තුරු  ඔබට  සුභ දවසක් ! ☺☺</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/">Components in Angular</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2019/01/24/components-in-angular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
