Angular 2 Components
By Nir Kaufman and Thierry Templier
()
About this ebook
A quick and concise guide to Angular 2 Components
About This Book- First look to the Angular 2 Components architecture
- Creating your own Angular 2 Component
- Integrating your components with third party components
If you are a front-end developer with some experience in Angular and want to understand Angular 2 Components, and easily put it to use to create powerful user interfaces and views, then this book is for you
What You Will Learn- Break your application into reusable dynamic components
- Take advantage of TypeScript in Angular 2
- Migrate your Angular 1 directive to an Angular 2 Component
- Understand the Angular 2 component structure and APIs
- Hook to component life cycle events
- Bind dynamic data to your component properties
- Communicate with other components using events
- Compose complicated UIs from simple components
This book is a concise guide to Angular 2 Components and is based on the stable version of Angular 2. You will start with learning about the Angular 2 Components architecture and how components differ from Angular directives in Angular 1. You will then move on to quickly set up an Angular 2 development environment and grasp the basics of TypeScript. With this strong foundation in place, you will start building components.
The book will teach you, with an example, how to define component behavior, create component templates, and use the controller of your component. You will also learn how to make your components communicate with each other. Once you have built a component, you will learn how to extend it by integrating third-party components with it. By the end of the book, you will be confident with building and using components for your applications.
Style and approachA step-by-step guide covering features and working of Angular 2 Components along with the process for creating your own components.
Related to Angular 2 Components
Related ebooks
Angular 2 Components Rating: 0 out of 5 stars0 ratingsAngular Design Patterns: Implement the Gang of Four patterns in your apps with Angular Rating: 0 out of 5 stars0 ratingsBeginning React: Simplify your frontend development workflow and enhance the user experience of your applications with React Rating: 0 out of 5 stars0 ratingsModern Web Development with Deno: Develop Modern JavaScript and TypeScript Code with Svelte, React, and GraphQL (English Edition) Rating: 0 out of 5 stars0 ratingsObject Oriented Programming with Angular: Build and Deploy Your Web Application Using Angular with Ease ( English Edition) Rating: 0 out of 5 stars0 ratingsSymfony2 Essentials Rating: 0 out of 5 stars0 ratingsApps and Services with .NET 8: Build practical projects with Blazor, .NET MAUI, gRPC, GraphQL, and other enterprise technologies Rating: 0 out of 5 stars0 ratingsDjango 1.0 Web Site Development Rating: 4 out of 5 stars4/5Learning AngularJS Animations Rating: 4 out of 5 stars4/5Advanced Express Web Application Development: For experienced JavaScript developers this book is all you need to build highly scalable, robust applications using Express. It takes you step by step through the development of a single page application so you learn empirically. Rating: 0 out of 5 stars0 ratingsReactJS for Jobseekers: The Only Guide You Need to Learn React and Crack Interviews (English Edition) Rating: 0 out of 5 stars0 ratingsLearn Angular: 4 Angular Projects Rating: 0 out of 5 stars0 ratingsBuild Applications with Meteor: Isomorphic JavaScript web development Rating: 0 out of 5 stars0 ratingsMastering Bootstrap 4 Rating: 5 out of 5 stars5/5Mastering Angular Components: Build component-based user interfaces with Angular Rating: 0 out of 5 stars0 ratingsKotlin Quick Start Guide: Core features to get you ready for developing applications Rating: 0 out of 5 stars0 ratingsImplementing AppFog Rating: 0 out of 5 stars0 ratingsMastering JavaScript Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsReact.js Design Patterns: Learn how to build scalable React apps with ease (English Edition) Rating: 0 out of 5 stars0 ratingsMastering MEAN Stack: Build full stack applications using MongoDB, Express.js, Angular, and Node.js (English Edition) Rating: 0 out of 5 stars0 ratingsCoding Languages: Angular With Typescript, Machine Learning With Python And React Javascript Rating: 0 out of 5 stars0 ratingsPersistence in PHP with Doctrine ORM Rating: 0 out of 5 stars0 ratingsGetting Started with OpenCart Module Development Rating: 0 out of 5 stars0 ratingsMastering JavaScript Design Patterns - Second Edition Rating: 5 out of 5 stars5/5Django Project Blueprints Rating: 0 out of 5 stars0 ratingsDeveloping with Docker Rating: 5 out of 5 stars5/5Svelte 3 Up and Running: A fast-paced introductory guide to building high-performance web applications with SvelteJS Rating: 0 out of 5 stars0 ratings
Computers For You
Storytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5Algorithms to Live By: The Computer Science of Human Decisions Rating: 4 out of 5 stars4/5Learn Algorithmic Trading: Build and deploy algorithmic trading systems and strategies using Python and advanced data analysis Rating: 0 out of 5 stars0 ratingsData Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Learn Data Warehousing in 24 Hours Rating: 0 out of 5 stars0 ratingsGrokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Practical Data Analysis Rating: 4 out of 5 stars4/5Becoming a Data Head: How to Think, Speak, and Understand Data Science, Statistics, and Machine Learning Rating: 5 out of 5 stars5/5Narrative Design for Indies: Getting Started Rating: 4 out of 5 stars4/5Mastering Blockchain Rating: 5 out of 5 stars5/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5Learn SAP MM in 24 Hours Rating: 0 out of 5 stars0 ratingsWordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsGet Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5Python for Finance Cookbook: Over 50 recipes for applying modern Python libraries to financial data analysis Rating: 0 out of 5 stars0 ratingsAdvances in Financial Machine Learning Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Python for Beginners: A Crash Course to Learn Python Programming in 1 Week Rating: 0 out of 5 stars0 ratingsData Visualization with Excel Dashboards and Reports Rating: 4 out of 5 stars4/5Dancing with Qubits: How quantum computing works and how it can change the world Rating: 5 out of 5 stars5/5The Alignment Problem: How Can Machines Learn Human Values? Rating: 4 out of 5 stars4/5Deep Learning with PyTorch Rating: 5 out of 5 stars5/5
Reviews for Angular 2 Components
0 ratings0 reviews
Book preview
Angular 2 Components - Nir Kaufman
Table of Contents
Angular 2 Components
Credits
About the Authors
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Angular 2 Component Architecture
The Model-View-Controller pattern
MVC in Angular 1
Moving from views to components
Defining components
Breaking the application into components
Summary
2. Setting Up an Angular 2 Development Environment with angular-cli
Node and npm
Installing Node
Introducing npm
Installing angular-cli
Generating an Angular 2 project
Choosing an IDE
Summary
3. The TypeScript Primer
Introduction to TypeScript
Managing dependencies with modules
The export and import statements
The default exports
Classes
The type system
The basic types
The custom types
About generics
Using decorators
Decorators versus annotations
Summary
4. Building a Basic Component
Bootstrapping the application
The component selector
Selector options
The component template
Embedding styles in component template
The shadow DOM
Encapsulation modes
Data bindings
Summary
5. Building Dynamic Components
Data interpolation
Core directives
NgIf
The asterisk – *
NgClass
NgStyle
NgSwitch
NgFor
Property bindings
Event bindings
Two-way bindings
Summary
6. Component Communication
Passing data via properties
Emitting custom events
Referencing with a local variable
Querying child components with the parent component
Summary
7. Putting It All Together
Preparing our development environment
The accordion component
Extending the accordion component tree
The component life cycle
Life cycle event interfaces
OnInit and OnDestroy
OnChanges
Other life cycle events
Summary
8. Integrating Third-Party Components
Preparing our development environment
Importing dependencies
Bootstrap tooltip component
Bootstrap collapse component
Summary
9. Angular 2 Directives
Components and directives in Angular 2
Preparing our development environment
The basic attribute directive
ElementRef and Renderer
Reacting to events from the host element
Passing properties to the directive
The basic structural directive
Summary
Index
Angular 2 Components
Angular 2 Components
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2016
Production reference: 1211116
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-234-0
www.packtpub.com
Credits
Authors
Nir Kaufman
Thierry Templier
Reviewers
Robin Böhm
Daniel Zen
Commissioning Editor
Sarah Crofton
Acquisition Editor
Meeta Rajani
Technical Editor
Narsimha Pai
Copy Editor
Laxmi Subramanian
Proofreader
Safis Editing
Indexers
Hemangini Bari
Pratik Shirodkar
Production Coordinators
Deepika Naik
Shantanu N. Zagade
Cover Work
Deepika Naik
About the Authors
Nir Kaufman is the Head of Angular Development at 500Tech, a leading front-end consultancy in Israel. He is a passionate JavaScript developer, an international speaker, and an Angular evangelist.
Nir runs three local Angular community meetup groups in Israel. He also collaborates with other local Angular communities around the world.
Thierry Templier is a senior full stack developer with 17 years of experience. He has been a JavaScript addict for a long time now and started to work with the early versions of the language. He has a particular passion for Angular 2 and loves to help developers to use this framework, particularly on the StackOverflow website, where he has answered more than 1,900 questions.
He also enjoys writing articles to promote and explain Angular 2's specific features on his blog (https://medium.com/@ttemplier/) and on the Restlet blog (http://restlet.com/blog/author/thierry-templier/).
Thanks to Nir, Meeta, and Narsimha for taking me on board and working with me on this project. Thanks to my beloved wife and son, Séverine and Maël, for their daily support.
About the Reviewers
Robin Böhm is a Germany based passionate trainer for Angular. He is also the co-founder of the AngularJS.DE platform, which is the biggest community for Angular in Germany. Together with his team, he offers intensive workshops and trainings for web development with Angular. Since 2013, they have successfully trained over 5000 developers from freelance developers to employees of large German corporate (DAX) companies.
Daniel Zen is a MIT graduate in Computer Science Engineering and has been teaching and writing software for the past three decades. He has taught computer programming and Agile methodologies at NYU, The New School, and at numerous Fortune 500 companies. He has worked on large-scale art projects, as well as interactive installations at the Museum of Science in Boston and The Milk Gallery in NYC. A former consultant to both Google and Pivotal Labs, Zen is now focused on zen.digital, a full stack JavaScript training and consulting company.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
eBooks, discount offers, and morehttps://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
Angular 2 is a leap forward from the previous Angular 1.x framework, which became the most popular frontend JavaScript framework in history.
It is a complete re-write, an up-to-date platform that