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.

Annotations
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

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

Actions
Our class defines actions that we can use in our view

Components
Components teach your browser new tags

Views
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

Reference:

Sam is a passionate web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and reading.

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 *