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
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
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
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/).
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.
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files availa...