Book Image

Mastering Angular 2 Components

By : Gion Kunz
Book Image

Mastering Angular 2 Components

By: Gion Kunz

Overview of this book

<p>Through this book, you will learn how to use Angular 2 and its component-based architecture in order to develop modern user interfaces. A new holistic way of thinking about UI development will be established throughout this book, and you will discover the power of Angular 2 components through many examples. This book is based on Release Candidate 1(RC1) of Angular 2.</p> <p>On this journey, you'll discover the benefits of component-based user interfaces over the classical MVC design. Also, you will get a chance to compare a classical MVC with a component-based approach and understand the challenges of modern user interfaces. You will learn the very basics of the required core technologies and the setup needed to get going with Angular 2, and progressively enhance your understanding of Angular 2 components by working on the example application.</p> <p>After reading the book and following the example application, you will have built a small-to-mid-sized application with Angular 2 using a component-based UI architecture.</p>
Table of Contents (19 chapters)
Mastering Angular 2 Components
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Supporting tag input


Here, we're going to build a component and its supporting structures to make the process of entering tags a smooth experience for our users. So far, they can write project tags, but it requires them to know the project IDs, which makes our tag management quite useless. What we'd like to do is provide the user with some choices when they are about to write a tag. Ideally, we show them the available tags, as soon as they start writing a tag by typing the hash (#) symbol.

What sounds simple in the first place is actually quite a tricky thing to implement. Our tag input needs to deal with the following challenges:

  • Handling input events to monitor tag creation. Somehow, we need to know when a user starts writing a tag, and we need to know when the typed tag name is updated or canceled by using an invalid tag character.

  • Calculating the position of the input caret of the user. Yeah, I know this sounds pretty simple, but it actually isn't. Calculating the viewport offset position...