Book Image

Switching to Angular 2

By : Minko Gechev
Book Image

Switching to Angular 2

By: Minko Gechev

Overview of this book

<p>AngularJS is a JavaScript framework that makes building web applications easier. It is used today in large-scale, high-traffic websites that struggle with under-performance, portability issues, as well as SEO unfriendliness, and complexity at scale.</p> <p>Angular 2 changes that.</p> <p>It is the modern framework you need to build performant and robust web applications. “Switching to Angular 2” is the quickest way to get to grips with Angular 2 and will help you transition in to the brave new world of Angular 2.</p> <p>We’ll start with an overview which sets the changes of the framework in context with version 1.x. After that, you will be taken on a TypeScript crash-course so we can take advantage of Angular 2 in its native, statically-typed environment. We’ll look at the new change-detection method in detail, how Directives and Components change how you create websites with Angular, the new Angular 2 router, and much more.</p> <p>By the end of the book, you’ll be ready to start building quick and efficient Angular 2 applications that take advantage of all the new features on offer.</p>
Table of Contents (16 chapters)
Switching to Angular 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction to TypeScript


TypeScript is an open source programming language that is developed and maintained by Microsoft. Its initial public release was in October 2012. TypeScript is a superset of ECMAScript, supporting all of the syntax and semantics of JavaScript with some extra features on top, such as static typing and richer syntax.

Fig. 1 shows the relationship between ES5, ES2015, ES2016, and TypeScript.

Fig. 1

Because TypeScript is statically typed, it can provide a number of benefits to us as JavaScript developers. Let's have a quick look at those benefits now.

Compile-time type checking

Some of the most common mistakes we make while writing JavaScript code is to misspell a property or a method name. We'll find out about the mistake when we get a runtime error. This can happen during development as well as in production. Hoping we will know about the error before we deploy our code to production environment isn't a comfortable feeling! However, this is not a problem specific to JavaScript...