Angular 2 Has a Lot of New Syntax

Angular 2

So I’ve been learning quite a bit of AngularJS 2 lately and want to share the new syntax it offers. This is from the ng-book mob but I will extend on it in the coming weeks.

The @ is an annotation and it comes from TypeScript

Multi-line Strings
Using ` backticks allows for easy inline templates

Brackets for Parameters
Use [] brackets on an attribute to pass parameters to the directive

Class Syntax
TypeScript allows you to define classes using the class syntax

One-way data binding means we fire events instead of modifying data directly

Our class defines actions that we can use in our view

Components teach your browser new tags

Views can be defined by the template option

Star Syntax
Use the * on an attribute to use a directive on this element

Parenthesis for View Actions
Use () parenthesis to specify action bindings

Strong Typing
TypeScript lets us define collections that contain our custom type Product

Component Definition Class
We define new Components with a class


Sam is a passionate web developer from England. In his spare time he enjoys coding, playing chess, reading and investing.

7 thoughts on “Angular 2 Has a Lot of New Syntax

Leave a Reply

Your email address will not be published. Required fields are marked *