<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karoon Sillapapan on Medium]]></title>
        <description><![CDATA[Stories by Karoon Sillapapan on Medium]]></description>
        <link>https://medium.com/@updev?source=rss-8c4cb58f98c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2Pkwp7NYZKqx2nPr.</url>
            <title>Stories by Karoon Sillapapan on Medium</title>
            <link>https://medium.com/@updev?source=rss-8c4cb58f98c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 00:34:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@updev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular7 First basic app (ตอนที่ 2)]]></title>
            <link>https://medium.com/@updev/angular7-first-basic-app-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-2-b4db6d87eca1?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4db6d87eca1</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 06:53:47 GMT</pubDate>
            <atom:updated>2019-06-07T06:53:47.322Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://angular.io/tutorial/toh-pt1#the-hero-editor">The Hero Editor</a></p><p>จากบทความ<a href="https://medium.com/@karoonsillapapan/angular-7-first-basic-app-%E0%B8%95%E0%B8%AD%E0%B8%99-1-66df0013b3ba">ที่แล้ว</a> เราจะสามารถสร้าง Project Angular และสามารถ run ได้เป็นครั้งแรก อารมณ์มันจะเหมือนๆ Hello World ในภาษาต่างๆ แต่ที่แตกต่างเลยคือวิธีที่จะทำให้มันสามารถ run ได้ นั้นต้องบอกว่า ง่ายสุด ^^</p><p>วันนี้เราจะลองมาทำการพัฒนา หน้าจอแก้ไขข้อมูลแบบ ง่ายๆสุดกันดูนะครับ</p><p>ก่อนจะเริ่มเรามาดูเป้าหมายกันก่อนนะครับ เป้าหมายของเราก็คือต้องการสร้างหน้าจอที่มีการแสดงค่า และแก้ไขได้จาก TextBox ตามรูปด้านล่าง ง่ายไหมครับ ^^</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*nn_HQ6MBBnpm7BBLgviujw.png" /></figure><p>จากที่เราเคยอ่านบทความพื้นฐานสิ่งที่เราควรต้องรู้ก่อนที่จะเขียน Angular มาแล้วเราจะรู้ว่า Angular นั้น จะมีส่วนที่สำคัญๆ ดังนี้</p><ol><li>ส่วนของ NgModule ซึ่งในส่วนนี้จะเป็นเหมือนที่รวม config ต่างๆของสิ่งที่จะ Import หรือ export จาก external Module ทั้งหมด และที่สำคัญคือเป็น ส่วนที่ Angular จะทำการอ่านค่าต่างๆ และทำการ Run project ดังนั้นถ้าตรงนี้หายก็ จบเลยครับ</li><li>ส่วนของ Component เป็นส่วนที่ จัดการทางด้าน Business logic ,การทำ Data Binding ให้กับ View,การ Communication ระหว่าง View to component และ component to view และอื่นๆอีกมากหมาย</li><li>ส่วนของ Pipe จะทำหน้าที่ในการให้บริการ Transform ข้อมูลที่มาจาก component เพื่อแสดงผลในส่วนของ View</li><li>Attribute directives การเปลี่ยนแปลง คุณลักษณ์ หรือ พฤติกรรมของแต่ละ Element ,component,และ another directive</li></ol><p>จากที่กล่าวมา 4 ข้อจะเป็นแค่สิ่งที่จำเป็นสำหรับการทำตามตัวอย่างของบทความนี้เท่านั้นนะครับ</p><p>เรามาเริ่มกันดีกว่าครับ</p><p><strong>Step 1</strong>: หลังจากเราทำการใช้คำสั่ง ng new angular-tour-of-heroes สำหรับสร้าง Project มาแล้ว เราก็จะได้ทุกสิ่งทุกอย่างที่เราต้องใช้ในการ Dev เรียบร้อยแล้ว พูดง่ายๆก็คือ เรามี NgModule เรียบร้อยแล้วนั้นเอง “src\app\app.module.ts”</p><p><strong>Step 2</strong> : เราจะมาทำการสร้าง Component แรกของเรา ให้มันชื่อว่า “heroes” โดยการใช้ Angular CLI</p><pre>ng generate component heroes</pre><p>สิ่งที่เราได้หลังจาก run command เราจะได้ folder ที่ชื่อว่า heroes และไฟล์อีก 4 file ตามรูป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*ZjEe5IHjOEpCGTvGl61NZA.png" /></figure><p>heroes.component.css =&gt; เป็นไฟล์ Css ที่จะมี scope แค่ใน component นี้เท่านั้น</p><p>heroes.component.html =&gt; เป็นไฟล์ html หรือก็คือ ViewTemplate สำหรับ component นี้เท่านั้น</p><p>heroes.component.spec.ts =&gt; อันนี้เป็น file Unit Test</p><p>heroes.component.ts =&gt; สุดท้ายก็คือ file component ของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*Wu2VTGC0kgy9-ITH1lvSTg.png" /></figure><p>พอเราไปที่ heroes.component.ts เราลองไปดูที่ Component decorator เราจะเห็นว่ามีการอ้างถึงในส่วนของ css และ html อยู่ด้วย</p><p>และอีกจุดที่น่าสนใจก็คือ selector : ‘app-heroes’ อันนี้ถ้าเข้าใจง่ายๆเลยมันก็คือ ตัว tag ของ Component ของเรา นั้นก็คือถ้ามี Component ไหนต้องการเอา component heroes ไปใช้ เข้าจะต้อง เอา &lt;app-heroes&gt;&lt;/app-heroes&gt; ไปว่างเอาไว้ในส่วน html template ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*hf1d5j0TXpgX5pTX4mD4gw.png" /></figure><p>นอกจากนี้สิ่งที่สำคัญอีกอย่างที่เราควรต้องรู้ก็คือ กรณีเรา run command ในการสร้าง Component ตัว Angular CLI จะทำการเอา Component heroes ไป declarations ที่ NgModule (src\app\app.module.ts) ให้โดยอัตโนมัติ ซึ่งถ้าเราทำการสร้างเอง โดยไม่ใช้ Angular CLI เราจะต้องไม่ลืมที่จะทำตรงส่วนนี้ด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*I47QIOFF2nsI9KX8cjI1wQ.png" /></figure><p><strong>Step 3 :</strong> ทำการสร้าง Hero Class เพื่อใช้เป็น Entity class สำหรับการเก็บข้อมูลเพื่อเอาไปแสดงผล โดยการสร้างนั้นเราสามารถทำการสร้าง Class โดยการ new file ปกติได้เลย หลังจากนั้นให้เราทำการ เพิ่ม properties ของ Class Hero นั้นก็คือ id และ Name ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*Z5SiNpX4Q7gNMlDd3vwuew.png" /><figcaption>src\app\hero.ts</figcaption></figure><p><strong>Step 4 : </strong>นำ Class Hero ไป initial value ใน heroes.component.ts โดยเราจะต้องทำการ import เข้าไปใน component ก่อน</p><pre>import {Hero} from ‘../hero’;</pre><p>หลังจากนั้นทำการสร้าง hero properties โดยให้ type เป็น Hero พร้อมทำการกำหนดค่าเริ่มต้นให้</p><pre>hero : Hero = {id:1,name:‘Wind storm’}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*SArVOLwPYnxK2JDa_8Mpfw.png" /><figcaption>src\app\heroes\heroes.component.ts</figcaption></figure><p>Step 5 : นำ properties hero binding ใน template ของเรา “src\app\heroes\heroes.component.html”</p><pre>&lt;div&gt;&lt;span&gt;id: &lt;/span&gt;{{hero.id}}&lt;/div&gt;</pre><pre>&lt;h2&gt; Details {{hero.name | uppercase}} &lt;/h2&gt;</pre><p>{{hero.id}} เป็นการทำ Data binding <a href="https://angular.io/guide/displaying-data#interpolation"><em>interpolation</em></a></p><p>{{hero.name | uppercase}} เป็นการทำ Data binding แต่มีการนะ pipe มาใช้ โดยใช้ คำสั่ง uppercase เพื่อให้แสดงผลตัวใหญ่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*0WzQX2iteWY5R38ac9p-fA.png" /></figure><p>Step 6 : ต่อไปเราจะทำในส่วนที่จะส่งค่า จาก View ไปยัง Component แต่ในคราวนี้เราต้องการที่จะสามารถทำการกรอกแล้วข้อมูลนั้นกลับไป ที่ Component และ กลับมาอัพเดตค่าใหม่ที่ View โดยทันที</p><p>ดังนั้นเราเลยจะใช้ในส่วนที่ Two-way binding โดยใช้ [(ngModel)] ซึ่งเป็น Attribute directives</p><p>โดยเริ่มจากเราต้องทำการ Import @angular/forms ไปที่ src\app\app.module.ts</p><pre>import { FormsModule } from ‘@angular/forms’; // ← NgModel lives here</pre><p>แลทำการ import FormsModule,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*8tMnonerPHIhTtD3QnWRFg.png" /><figcaption>src\app\app.module.ts</figcaption></figure><p>เราก็จะสามารถใช้ [(ngModel)] ใน Module ของเราได้แล้ว</p><p>ต่อไปเราก็ไปจัดการในส่วนของ component heroes ของเราต่อ โดยทำการเพิ่ม tag input ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*8mp6aY00LKe61yW49RYlrA.png" /><figcaption>src\app\heroes\heroes.component.html</figcaption></figure><pre>&lt;input [(ngModel)]=”hero.id” placeholder=”id”/&gt;<br>&lt;input [(ngModel)]=&quot;hero.name&quot; placeholder=&quot;name&quot;/&gt;</pre><p>เราได้ทำการใช้ [(ngModel)] mapping ไปที่ field id และ name ของ Object hero ดังนั้นถ้า User มีการกรอกข้อมูลลงไปใน Input 2 ตัวนี้ ค่าที่กรอกไปจะส่งไปที่ Object ดังกล่าวใน Component ทันที พร้อมกับอัพเดตไปที่ จุดที่มีการเรียกใช้ object ดังกล่าวในส่วนของ View โดยอัตโนมัติ</p><pre>&lt;div&gt;&lt;span&gt;id: &lt;/span&gt;{{hero.id}}&lt;/div&gt;</pre><pre>&lt;h2&gt; Details {{hero.name | uppercase}} &lt;/h2&gt;</pre><p>และพอเราทำการทดสอบ run ผลที่ได้ก็จะเป็นดังรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*UR8y1iqo6d4qRjwVeQ3dEw.png" /></figure><p>ในส่วนของ sourcecode ทั้งหมดผมได้อัพขึ้น Git แล้วนะครับ</p><p><a href="https://github.com/ksupdev/angular-tour-of-heroes">ksupdev/angular-tour-of-heroes</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4db6d87eca1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 7 first basic app (ตอน 1)]]></title>
            <link>https://medium.com/@updev/angular-7-first-basic-app-%E0%B8%95%E0%B8%AD%E0%B8%99-1-66df0013b3ba?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/66df0013b3ba</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Thu, 06 Jun 2019 07:32:08 GMT</pubDate>
            <atom:updated>2019-06-06T07:32:08.286Z</atom:updated>
            <content:encoded><![CDATA[<p>เริ่มต้นการเตรียม environment และ start application ครั้งแรก <a href="https://angular.io/tutorial#tour-of-heroes-app-and-tutorial">REF</a></p><p><strong>Prepare environment development</strong></p><ol><li>ทำการ Install NodeJS ซึ่งผมคงจะไม่พูดถึงนะครับ (<a href="https://blog.teamtreehouse.com/install-node-js-npm-windows">How to install</a> แต่ถ้าว่างๆจะรวบรวมให้นะครับ) โดยเราสามารถตรวจสอบ โดยใช้คำสั่ง</li></ol><pre>node -v <br>output : v8.11.2</pre><p>2. ทำการ Install Angular CLI โดยใช้ npm (Package management)</p><pre>npm install -g @angular/cli</pre><p>หลังจากนั้นเราลองใช้คำสั่ง ng --version จะแสดงผลตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*Njt8iPG-5soSvcu7exJ0IQ.png" /></figure><p>ซึ่งหลังจากเราทำ 2 Steps เรียบร้อยก็สามารถเริ่มต้นกับ Angular ได้แล้วครับ ^^</p><h3>Create a new workspace and an initial application</h3><p>ถึงเวลาสนุกแล้ว ..</p><p><strong>Step : 1 </strong>เราจะเริ่มจากการสร้าง Project Angular โดยใช้ Angular CLI ผ่าน command</p><pre>ng new angular-tour-of-heroes</pre><p>โดยคำสั่งนี้จะเป็นการ สร้าง Project Angular ที่ชื่อ angular-tour-of-heroes โดย Angular CLI นั้นจะ Generate ตัวไฟล์ ที่ต้องการและ Project structure ให้ทั้งหมด</p><p>หลังจากเราทำการ run command แล้ว AngularCLI จะมีคำถามเกี่ยวการ config จำพวก Angular Router และ CSS เราสามารถตอบ ได้ตามรูปด้านล่างเลยครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*dj1FR0mHPAznaZE2RtUT0Q.png" /></figure><p>หลังจากนั้น AngularCLI จะเริ่มทำการ Generate Project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpAeqiZ4boPBlJfb9IhNUQ.png" /></figure><p>หลังจากเราทำการ Create โปรเจคเรียบร้อย ก็จะสามารถทำการ run คำสั่งเพื่อทำการ Start Application ขอเราได้ทันที</p><pre>ng serve --open</pre><p>และเราก็จะได้ผลลัพธ์ตาม ภาพด้านล่างทันทีครับ โดย Application ของเรานั้นจะ run อยู่ที่ http://localhost:4200/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*bEAuIXaixXssuuqPj76ZKA.png" /><figcaption><a href="http://localhost:4200/">http://localhost:4200/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*cuJdFuouTk_sDHiqx_Pjiw.png" /><figcaption>Project structure ที่ได้จากการ generate</figcaption></figure><p>เมื่อ run command ng serve — open ระบบจะทำการ auto refresh ทุกครั้งที่มีการแก้ไขข้อมูล ใน component ตัวอย่างถ้าเราทำการ แก้ไข title = ‘Tour of Heroes’; ใน file app.component.ts หน้า Web ก็จะทำการ refresh ในส่วนของ Title ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*1h7SuOk93AF2zaMSeRLEZw.png" /></figure><p><strong>Step : 2</strong> หลังจากนั้นเรามาเริ่มทำการแก้ไข Sourcecode ง่ายๆดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*IDczdIg84XUMHrMq6krgtg.png" /><figcaption>src\app\app.component.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*KQPXCF5hbmsU8RZH8mu-kQ.png" /><figcaption>src\app\app.component.ts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*7RgxeoNzpcmoX4JwjHPITw.png" /><figcaption>src\styles.css</figcaption></figure><p>หลังจากการแก้ทุกอย่างเรียบร้อย Application ก็จะทำการ Refresh และแสดงตามรูป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*yM2RPQGvW3YGXEc7OEbfnA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66df0013b3ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular7 (โคตร basic. 3)]]></title>
            <link>https://medium.com/@updev/angular7-%E0%B9%82%E0%B8%84%E0%B8%95%E0%B8%A3-basic-3-cc177656a60a?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc177656a60a</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Wed, 05 Jun 2019 09:30:57 GMT</pubDate>
            <atom:updated>2019-06-05T09:30:57.411Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://angular.io/guide/ngmodule-vs-jsmodule#javascript-modules-vs-ngmodules">JavaScript Modules vs. NgModules</a></p><h3>JavaScript modules</h3><p>file Javascript 1 file เราจะถือว่าเป็น 1 Modules ซึ่งนั้นก็หมายความว่า การประกาศ Object อะไรก็แล้วแต่ใน file นั้นถือว่าเป็น feature ของ module ในทันที นั้นก็หมายความว่า ถ้ามี feature สัก 100 line of code ก็จะ Depend by feature ทันที</p><p>ดังนั้น ถ้าอยากจะให้มีการเรียกใช้งาน Feature ใน Module เราจำเป็นต้องมีการประกาศ export เพื่อให้ Module อื่นๆสามารถเรียกใช้งานได้โดยการใช้คำสั่ง import</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*40g1YpmjyKhS_JSyQuTR8A.png" /></figure><h3>NgModules</h3><p>เป็นการสร้าง Javascript class แล้วทำการระบุ decorated <a href="https://medium.com/@karoonsillapapan/angular-7-basic-%E0%B9%82%E0%B8%84%E0%B8%95%E0%B8%A3%E0%B9%86-2-4721216b906d">@NgModule</a> เพื่อที่จะบอกกับ Angular ว่า Class นี้เป็น Root Module เพื่อเอาไว้สำหรับกำหนด ค่าต่างๆของ Module นี้</p><p>ดังนั้นความแตกต่างที่ชัดเจนที่สุดนั้นก็คือ NgModules นั้นจะทำหน้าที่เหมือนตัวกลางที่ให้ Angular นั้นมาดูว่า Module มี features อะไรบ้าง มีองค์ประกอบอะไร และมีการนำเอาไรจากภายนอกเข้ามาใช้บ้าง นั้นก็คือสามารถ import หรือ export ได้เหมือนกับ Javascript module นั้นเอง ..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc177656a60a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 7 (Basic โคตรๆ 2)]]></title>
            <link>https://medium.com/@updev/angular-7-basic-%E0%B9%82%E0%B8%84%E0%B8%95%E0%B8%A3%E0%B9%86-2-4721216b906d?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4721216b906d</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Wed, 05 Jun 2019 08:28:32 GMT</pubDate>
            <atom:updated>2019-06-05T08:28:32.730Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://angular.io/guide/architecture-modules">Introduction to modules</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_rm8YTN9KlK-9nBqVjcpPw.png" /><figcaption>Credit by : <a href="https://angular.io/guide/architecture#whats-next">https://angular.io/guide/architecture#whats-next</a></figcaption></figure><p>An NgModule นั้นจะประกอบไปด้วย components ต่างๆ ที่มีความเกี่ยวข้องกัน และถูกนำไปใช้งานตามแต่ละ วัตถุประสงค์ โดยแต่ละ NgModule นั้นจะประกอบไปด้วย components ,service providers และ code file ต่างๆ โดยทั้งหมดจะต้องถูกกำหนดใน NgModule นอกจากนี้ NgModule นั้นสามารถ import import function หรือ Export function กับ Other NgModule อื่นๆได้</p><p>โดยในแต่ละ NgModule จะต้องมี root module 1 อันเสมอและจะใช้ชื่อว่า <strong>AppModule </strong>(app.module.ts) โดย file นี้จะทำหน้าที่ในการ start application</p><h3>NgModule metadata</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*4DixsZmsUroHzfxgFUbPQA.png" /><figcaption>Credit by : <a href="https://angular.io/guide/architecture-modules#ngmodule-metadata">https://angular.io/guide/architecture-modules#ngmodule-metadata</a></figcaption></figure><p>imports : ใช้ในการ import other module เข้ามาใช้งาน</p><p>providers : เป็นการระบุในส่วนของ service (จะมีรายละเอียดเพิ่มเติมว่า Service คืออะไรในภายหลัง…)</p><p>declarations : เป็นการระบุ components,directives,pipes ที่ใช้งานภายใน NgModule นี้</p><p>exports: เป็นการระบุชื่อสำหรับกรณีต้องการ export ให้กับ other NgModule เรียกใช้งาน</p><p>bootstrap : ใช้สำหรับระบุ Class ที่เป็น Root component</p><h3>NgModules and components</h3><p>ใน NgModules นั้นสามารถมีการเพิ่ม Component โดยการทำผ่าน Router หรือ Create ผ่าน Template ซึ่ง Component ทั้งหมดนั้นจะแชร์ Compilation Context รวมกัน</p><blockquote>Compilation Context</blockquote><blockquote>The compilation context is basically just a fancy term for grouping of the files that TypeScript will parse and analyze to determine what is valid and what isn’t. Along with the information about which files, the compilation context contains information about <em>which compiler options</em> are in use. A great way to define this logical grouping (we also like to use the term <em>project</em>) is using a tsconfig.json file.</blockquote><p>โดยปกติ component จะมีเพียง view เดียวซึ่งเราจะเรียกว่าเป็น Host View แต่ใน HostView นั้นสามารถมี View ของ Component อื่นๆอยู่ภายใต้ได้โดยไม่ได้จำกัดในมุมของความลึก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*fj3AQAyg-V_wjReTnpAFzw.png" /></figure><h3>NgModules and JavaScript modules</h3><p>NgModule นั้นต่างจากและไม่ได้เกี่ยวข้องกับ the JavaScript (ES2015) module system อะไรทั้งนั้น แต่คุณสามารถเอามาใช้เป็น Module เสริมสำหรับการทำงานของ Application ของคุณได้</p><p>โดยใน <a href="https://exploringjs.com/es6/ch_modules.html">Javascript</a> นั้นจะมองว่า 1 file นั้นก็คือ 1 module โดยถ้ามีการประกาจ Object ต่างๆขึ้นมาใน File ก็จะถือว่าอยู่ภายใต้ Module เดียวกันดังนั้น ถ้าต้องการให้ Module อื่นเรียกใช้งาน หรือจะเรียก Module อื่นๆใช้งานจึงจำเป็นต้องทำการ Import และ Export</p><p>ดังนั้นโดยส่วนตัวนั้นผมมองว่าเป็นแนวคิดที่มีความใกล้เคียงกันมาก .</p><h3>Angular libraries</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*c_umFOMEPnepV5NSc7fzPw.png" /></figure><p>Angular ได้ทำการรวมรวม Javascript module ต่างๆเพื่อสำหรับนำมาใช้งานใน โดยผู้ใช้งานนั้นสามารถ Install node package manager npm</p><p>แล้วจึงสามารถทำการ Import เข้ามาใช้งานได้ โดยเราจะสังเกตุง่ายๆ ก็คือ Angular libraries นั้นจะมี prefix @angular อยู่ด้านหน้า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*x0QcKQvD-5zEuKzpHJzCrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*UvRbQwYpOEkQihLskMscPw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4721216b906d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 7 (basic โคตร 1)]]></title>
            <link>https://medium.com/@updev/angular-7-basic-%E0%B9%82%E0%B8%84%E0%B8%95%E0%B8%A3-1-3a50f1bade7b?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a50f1bade7b</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Tue, 04 Jun 2019 08:30:12 GMT</pubDate>
            <atom:updated>2019-06-04T08:30:12.057Z</atom:updated>
            <content:encoded><![CDATA[<p>Introduction to components… [ref : <a href="https://angular.io/guide/architecture-components">https://angular.io/guide/architecture-components</a>]</p><p><strong>Component </strong>นั้นจะมีหน้าที่สำหรับการ control ในส่วนของ view</p><blockquote>โดยแต่ละ component นั้นจะสามารถ control ได้เพียง view เดียวเสมอ</blockquote><p><strong>คำถาม</strong> : แล้ว control อะไรละ ?….. โดยปกติ View ก็ส่วนในการแสดงผลข้อมูลตามที่ได้มีการส่งให้ พูดง่ายๆคือส่งอะไรมาก็แสดงหมด อ่ะและ ดังนั้นการที่จะบอกว่าแสดงอะไร ด้วยเงื่อนไขอะไร หรือต้องไปเอาข้อมูลมาจากไหน จึงกลายเป็นหน้าที่ของ Component โดยปริยาย.</p><h3>Component metadata</h3><p>เข้าใจง่ายก็คือ การประกาศให้ Angular รู้ว่า Class นี้เป็น Component พร้อมกับระบุ คุณสมบัติต่างๆ ของ Component นั้นเข้าไปด้วย “ซึ่งถ้าเป็นคนที่เขียน Java มากก่อนจะรู้จักมันในนาม Anotation “ โดยวิธีในการประกาศนี้เราจะใช้ @Component <a href="https://www.typescriptlang.org/docs/handbook/decorators.html">decorator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*RehDSLQ-Me3HJLJkVebFCA.png" /></figure><p>โดยปกติ Option สำหรับ @Component ที่เรามักจะเจอกันบ่อยๆมีดังนี้</p><ul><li>selector : จะทำงานเหมือนกับ Css Selector ใช้ในการระบุจุดที่เป็นพื้นที่แสดงผลของ Component นั้นๆ จากรูปด้านบนเราจะเห็น ‘app-hero-list’ นั้นก็หมายความว่า componet HeroListComponent นั้นจะมีการแสดงผลใน &lt;app-hero-list&gt;&lt;/app-hero-list&gt; เท่านั้น</li><li>templateUrl : ใช้ในการกำหนด Template หรือก็คือ html script ต่างๆที่ใช้สำหรับการแสดงผลของ component นั้น ซึ่งเราสามารถแทรกเป็น html inline หรืออาจจะใช้เป็น file.html เลยก็ได้ แต่ที่ สำคัญ เราสามารถระบุ tag ที่เป็น component อื่นๆ มาใส่ภายใต้ component นี้ได้</li><li>providers : คือการนำเขา Class ที่มีการ implement <a href="https://angular.io/guide/glossary#provider">Providor interfaces </a>(DI) โดยเราจะมาลง Detail กันอีกทีนะครับ ^^</li></ul><h3>Templates and views</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*sLX4UfGZY1R_DgyQ6u3tow.png" /><figcaption>credit by <a href="https://angular.io/guide/architecture-components#templates-and-views">https://angular.io/guide/architecture-components#templates-and-views</a></figcaption></figure><p>Template คือการใช้ HTML tag หรืออาจจะใช้ component อื่นๆมากำหนดรูปแบบสำหรับการแสดงผลของ Component ที่เป็น Host</p><p>โดยลักษณะในการว่างนั้นจะแบ่งออกเป็นชั้นๆ เหมือนกับการ Html ทั่วๆไป สำหรับการนำ component อื่นๆมาไว้ใน Template นั้นเราสามารถเอามาได้จาก <a href="https://angular.io/guide/ngmodules">NgModule </a>เดียวกันหรือคนละ NgModules ก็ได้</p><h3>Template syntax</h3><p>จะประกอบด้วยการทำงาน หรือคำสั่งต่างจัดการเกี่ยวกับการนำข้อมูลหรือการ check condition ต่างๆกับ Component ที่มีการใช้งาน Template นี้</p><p>โดย Template syntax จะประกอบไปด้วย Data binding ,Pipes ,directives</p><p><strong>Data binding</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*p90g1uQsGAjV8eR8t7yR4Q.png" /><figcaption>Credit by : <a href="https://angular.io/guide/architecture-components#data-binding">https://angular.io/guide/architecture-components#data-binding</a></figcaption></figure><p>เอาที่เข้าใจง่าย Data binding คือ ways of communication between view and component. จบ โดย Data binding นั้นจะแบ่งเป็น 2 ปรเภทใหญ่ๆคือ One way data binding และ Two way data binding</p><p><strong>One way data binding</strong> จะมีเยอะมาก แต่เราจะขอยกมาแค่ 3 ตัวก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*7JNVyaTj_HrbRN7yfLhZjg.png" /></figure><ul><li><a href="https://angular.io/guide/displaying-data#interpolation"><em>interpolation</em></a><em> : </em>การ binding ข้อมูลจาก Component {{value}}</li><li><a href="https://angular.io/guide/template-syntax#property-binding"><em>property binding</em></a><em> : </em>การ ส่งค่าจาก Host component ให้กับ component ที่อยู่ภายใต้ผ่านทาง property หรืออาจะทำการกำหนดค่าให้ กับ tag HTML ปกติก็ได้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*jVlzEQKPf7F6T9M8gGiJqg.png" /><figcaption>Credit by : <a href="https://angular.io/guide/template-syntax#property-binding-or-interpolation">https://angular.io/guide/template-syntax#property-binding-or-interpolation</a></figcaption></figure><ul><li><a href="https://angular.io/guide/user-input#binding-to-user-input-events"><em>event binding</em></a><em> : ใช้สำหรับ handle event ที่เกิดในส่วนของ View</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*LONfcXNJxnqL1T9kkRPlKw.png" /><figcaption>basic event credit by : <a href="https://www.positronx.io/useful-list-of-angular-7-event-types-for-event-binding/">https://www.positronx.io/useful-list-of-angular-7-event-types-for-event-binding/</a></figcaption></figure><p><strong>Two way data binding </strong>คือตัวช่วยในการแรกเปลี่ยนข้อมูลทั้งจาก View ไป component และจาก component ไป View โดยผ่าน ngModel directive หรือถ้ามองอีกมุมมันก็คือการ combines property and event binding in a single notation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ef-6LJwPYvOw0jUcJqZUQA.png" /><figcaption>Credit by <a href="https://www.pluralsight.com/guides/one-and-two-way-data-binding-angular">https://www.pluralsight.com/guides/one-and-two-way-data-binding-angular</a></figcaption></figure><h3>Pipes</h3><p>ทำหน้าทีในการ ปรับรูปแบบในการแสดงผลของข้อมูลที่ได้รับมาจาก Component ซึ่งจะมี function ให้เราเลือกใช้งานเป็น<a href="https://angular.io/api?type=pipe">จำนวนมาก</a></p><p>โดยการใช้งานจะใช้ใน interpolation binding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*4xdb_Eof9HqiCqkmQ6NvNQ.png" /></figure><h3>Directives</h3><p>คือชุดคำสั่งในการเปลี่ยนแปลงรูปแบบการแสดงผลของ DOM ในแต่ละรูปแบบ ซึ่งจะมี 3 ประเภท</p><ol><li>Components : เป็นการเปลี่ยนแปลง DOM โดยการใช้ Template ที่กำหนดในแต่ละ componentes</li><li>Structure directives : การเปลี่ยนแปลง โดยการ เพิ่มหรือลบ DOM Element</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*-wLRG5YTdwVxj3zD17RZUg.png" /></figure><p>3. Attribute directives : การเปลี่ยนแปลง คุณลักษณ์ หรือ พฤติกรรมของแต่ละ Element ,component,และ another directive</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*TGlgIkHEK4J2auC6POLIcA.png" /></figure><p>REF : <a href="https://angular.io/guide/architecture-components">https://angular.io/guide/architecture-components</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a50f1bade7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello world with Spring-boot Version 2.1.5]]></title>
            <link>https://medium.com/@updev/hello-world-with-spring-boot-version-2-1-5-8a059afb89a9?source=rss-8c4cb58f98c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a059afb89a9</guid>
            <dc:creator><![CDATA[Karoon Sillapapan]]></dc:creator>
            <pubDate>Tue, 28 May 2019 07:23:45 GMT</pubDate>
            <atom:updated>2019-05-28T07:23:45.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*YHzV5473rTN2cLl9s6ESHw.png" /></figure><p>สำหรับผู้เริ่มต้น ทั้งผู้เขียนและผู้อ่าน ^^</p><h3><strong>Prepare environment</strong></h3><ol><li>You have to the Java latest on your laptop (I used version 1.8)</li><li>You have to install Maven. you can install follow this <a href="https://www.mkyong.com/maven/how-to-install-maven-in-windows/">https://www.mkyong.com/maven/how-to-install-maven-in-windows/</a></li></ol><h3>Setup Spring-boot project by Spring Initialize</h3><p>Spring community has provide the Spring Initialize is easy way to get start your project and who has interesting to use it.</p><p>โดยผมจะใช้ Spring Initialize สร้าง Project ที่เป็น Restful API ซึ่งจะมีขั้นตอนดังนี้</p><p><strong>Step 1</strong> : Go to <a href="https://start.spring.io/">https://start.spring.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*lZHneFN_C5zfJH8pQ-2FnQ.png" /></figure><p>เมื่อเราทำการกรอกข้อมูลเรียบร้อยตามรูป ให้ทำการกดปุ่ม Generate Project เพื่อทำการ Download เป็น Zip file</p><blockquote>จากรูป เราสามารถที่จะเลือก dependencies ที่จะให้ import ไปใน file pom ให้อัตโนมัติ</blockquote><p><strong>Step 2 :</strong> ทำการ extract zip file project และเปิด Project ด้วย IDE ที่ใช้งาน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*ws3f737c6gt4hSjdzml-cw.png" /></figure><p><strong>Step 3</strong> : Open project by Intellij IDE. Go to menu File-&gt;New-&gt;Project from Exiting Source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*80wfvBzYcN5xukAwcb3uyw.png" /><figcaption>Choose you project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*HcWFLJmy0Bp5OEfMztMBsA.png" /><figcaption>Choose Maven</figcaption></figure><p>After choose Maven,you can next all then until finish</p><p>Step 4 : You have to add The actuator dependency in to file pom.xml which use for monitoring service status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*4AYWgureR1wj6RJ53n_Plw.png" /><figcaption>file pom.xml</figcaption></figure><p><strong>Step 5 </strong>: ไปที่ file application.properties “src\main\resources\application.properties” และทำการเพิ่มในส่วนของ</p><pre>server.port = 8099<br>server.servlet.context-path = /firstservice</pre><p>server.port ใช้สำหรับการระบุ port ที่ใช้ในการ run service ส่วน server.servlet.context-path นั้นใช้สำหรับระบุ context-path</p><p>Step 6: ทำการทดสอบการ Run Project</p><pre>mvn clean compile spring-boot:run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*bNIbPppyCw13YTPu0qoTLw.png" /></figure><p>หลังจากทำการ Run และได้ผลลัพธ์ตามภาพ เราก็จะสามารถทดสอบเรียก ตาม URL <a href="http://localhost:8099/firstservice/actuator">http://localhost:8099/firstservice/actuator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*1lhyHTSU8_sYgyCMiaFVgA.png" /><figcaption>Response from <a href="http://localhost:8099/firstservice/actuator">http://localhost:8099/firstservice/actuator</a></figcaption></figure><p>สำหรับบทความนี้เป็นบทความแรกของผม (สารภาพเลยเขียนไม่เป็น 555555) ใช้สำหรับการ remind ตัวเองเท่านั้นและก็จะพยายามเอาสิ่งที่เคยทำมาเขียนเพิ่ม ที่ละนิด ^^</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a059afb89a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>