# Directives และ Pipes (Angular) > Built-in directives, custom directives, attribute directives, structural directives, built-in pipes, custom pipes, pure vs impure pipes - 22 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Angular](https://sharpskill.dev/th/technologies/angular/interview-questions.md) ## 1. Structural directive ใน Angular คืออะไร? **คำตอบ** Structural directives ปรับเปลี่ยนโครงสร้าง DOM โดยการเพิ่ม ลบ หรือจัดการองค์ประกอบ มีสัญลักษณ์ * นำหน้า (เช่น *ngIf, *ngFor) ต่างจาก attribute directives ที่ปรับเปลี่ยนลักษณะหรือพฤติกรรม structural directives สามารถเพิ่มหรือลบองค์ประกอบจาก DOM ได้ ## 2. syntax ที่ถูกต้องสำหรับการใช้ ngFor กับ trackBy คืออะไร? **คำตอบ** syntax ที่ถูกต้องใช้เซมิโคลอนเพื่อแยก iteration จากฟังก์ชัน trackBy ฟังก์ชัน trackBy ปรับปรุงประสิทธิภาพโดยอนุญาตให้ Angular ระบุได้ว่ารายการใดมีการเปลี่ยนแปลง ถูกเพิ่ม หรือถูกลบ ฟังก์ชันนี้รับสองพารามิเตอร์ (index และ item) และคืนค่า identifier ที่ไม่ซ้ำกัน ## 3. ทำไมต้องใช้ trackBy กับ ngFor? **คำตอบ** trackBy ปรับปรุงประสิทธิภาพการ render รายการโดยอนุญาตให้ Angular ระบุได้อย่างแม่นยำว่ารายการใดมีการเปลี่ยนแปลง หากไม่มี trackBy Angular จะสร้าง DOM elements ทั้งหมดใหม่เมื่อเกิดการเปลี่ยนแปลง ด้วย trackBy จะมีเพียงรายการที่แก้ไขเท่านั้นที่ถูกอัปเดต หลีกเลี่ยงการสร้างใหม่ที่ไม่จำเป็น ## มีอีก 19 คำถาม - ควรใช้ directive ใดเพื่อแสดงองค์ประกอบตามเงื่อนไข? - ความแตกต่างระหว่าง *ngIf และ [hidden] คืออะไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Angular อื่นๆ - [พื้นฐาน TypeScript](https://sharpskill.dev/th/technologies/angular/interview-questions/typescript-basics.md): 25 คำถาม, Junior - [TypeScript ขั้นสูง](https://sharpskill.dev/th/technologies/angular/interview-questions/typescript-advanced.md): 20 คำถาม, Junior - [พื้นฐาน Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-fundamentals.md): 20 คำถาม, Junior - [คอมโพเนนต์และวงจรชีวิต](https://sharpskill.dev/th/technologies/angular/interview-questions/components-lifecycle.md): 20 คำถาม, Junior - [Services & Dependency Injection](https://sharpskill.dev/th/technologies/angular/interview-questions/services-dependency-injection.md): 20 คำถาม, Junior - [การจัดระเบียบโมดูล Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/modules-organization.md): 22 คำถาม, Mid-Level - [Angular CLI](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-cli.md): 18 คำถาม, Junior - [Routing และการนำทาง](https://sharpskill.dev/th/technologies/angular/interview-questions/routing-navigation.md): 24 คำถาม, Mid-Level - [Reactive Forms](https://sharpskill.dev/th/technologies/angular/interview-questions/forms-reactive.md): 26 คำถาม, Mid-Level - [Template-driven Forms](https://sharpskill.dev/th/technologies/angular/interview-questions/forms-template-driven.md): 16 คำถาม, Mid-Level - [พื้นฐาน RxJS](https://sharpskill.dev/th/technologies/angular/interview-questions/rxjs-fundamentals.md): 22 คำถาม, Mid-Level - [Operator ของ RxJS](https://sharpskill.dev/th/technologies/angular/interview-questions/rxjs-operators.md): 24 คำถาม, Mid-Level - [HttpClient และการเรียก API](https://sharpskill.dev/th/technologies/angular/interview-questions/http-client.md): 22 คำถาม, Mid-Level - [การจัดการ state พื้นฐาน](https://sharpskill.dev/th/technologies/angular/interview-questions/state-management-basics.md): 20 คำถาม, Mid-Level - [Change Detection](https://sharpskill.dev/th/technologies/angular/interview-questions/change-detection.md): 20 คำถาม, Mid-Level - [Angular Signals](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-signals.md): 20 คำถาม, Mid-Level - [Standalone Components](https://sharpskill.dev/th/technologies/angular/interview-questions/standalone-components.md): 18 คำถาม, Mid-Level - [การทำ Unit Testing ใน Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/testing-unit.md): 22 คำถาม, Mid-Level - [การทดสอบ End-to-End](https://sharpskill.dev/th/technologies/angular/interview-questions/testing-e2e.md): 18 คำถาม, Mid-Level - [Build และการเพิ่มประสิทธิภาพ](https://sharpskill.dev/th/technologies/angular/interview-questions/build-optimization.md): 20 คำถาม, Mid-Level - [พื้นฐาน NgRx](https://sharpskill.dev/th/technologies/angular/interview-questions/ngrx-fundamentals.md): 24 คำถาม, Senior - [NgRx ขั้นสูง](https://sharpskill.dev/th/technologies/angular/interview-questions/ngrx-advanced.md): 24 คำถาม, Senior - [สถาปัตยกรรม Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-architecture.md): 22 คำถาม, Senior - [การปรับแต่งประสิทธิภาพ](https://sharpskill.dev/th/technologies/angular/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [ความปลอดภัยและแนวทางปฏิบัติที่ดี](https://sharpskill.dev/th/technologies/angular/interview-questions/security-best-practices.md): 20 คำถาม, Senior - [รูปแบบ RxJS ขั้นสูง](https://sharpskill.dev/th/technologies/angular/interview-questions/advanced-rxjs-patterns.md): 22 คำถาม, Senior - [Angular Universal และ SSR](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-universal-ssr.md): 20 คำถาม, Senior - [Angular Micro-frontends](https://sharpskill.dev/th/technologies/angular/interview-questions/micro-frontends-angular.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/angular/interview-questions/directives-pipes