Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Angular 2 Components
Angular 2 Components
Angular 2 Components
Ebook225 pages1 hour

Angular 2 Components

Rating: 0 out of 5 stars

()

Read preview

About this ebook

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
LanguageEnglish
Release dateNov 30, 2016
ISBN9781785889400
Angular 2 Components

Related to Angular 2 Components

Related ebooks

Internet & Web For You

View More

Related articles

Reviews for Angular 2 Components

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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 for more details.

    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.

    https://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

    Enjoying the preview?
    Page 1 of 1