Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering TypeScript - Fourth Edition

You're reading from  Mastering TypeScript - Fourth Edition

Product type Book
Published in Apr 2021
Publisher Packt
ISBN-13 9781800564732
Pages 538 pages
Edition 4th Edition
Languages
Author (1):
Nathan Rozentals Nathan Rozentals
Profile icon Nathan Rozentals

Table of Contents (19) Chapters

Preface 1. Up and Running Quickly 2. Exploring the Type System 3. Interfaces, Classes, Inheritance, and Modules 4. Generics and Advanced Type Inference 5. Asynchronous Language Features 6. Decorators 7. Integration with JavaScript 8. Strict Compiler Options 9. Using Observables to Transform Data 10. Test-Driven Development 11. Angular 12. React 13. Vue 14. Node and Express 15. An AWS Serverless API 16. Micro Front-ends 17. Other Books You May Enjoy
18. Index

Angular forms

When building single-page applications, we will often need a user to input data of some sort using a form. Angular uses a two-way data binding process to bind values that are entered on a form to variables within a component itself. This process is two-way, as Angular will take care of synchronizing what is shown in the DOM with the member variables of a component. So if we change a value programmatically within our code, this value will be updated in the HTML. Similarly, when a user modifies the HTML values, these values will automatically update our class member variables.

Angular actually has two different methods of creating two-way data binding forms. The first method is named template forms, which allows us to bind an input control directly to a property on our class, as follows:

<input type="text" [(ngModel)]="name" /> 

Here, we have an input control within our HTML template, which is using the [(ngModel)] attribute with...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}