{"id":12906,"date":"2016-06-01T12:15:30","date_gmt":"2016-06-01T09:15:30","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=12906"},"modified":"2016-05-26T18:20:42","modified_gmt":"2016-05-26T15:20:42","slug":"first-steps-angular-2-8-cool-features","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/","title":{"rendered":"First steps with Angular 2: 8 cool features"},"content":{"rendered":"<p>I&#8217;ve been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really natural and straightforward while working with it. No more string based dependency injection, or strange digest cycle stuff, it just seems to work. This last week I&#8217;ve migrated our beta-13 Angular app to the latest rc-1, and used that to keep track of the fun and easy stuff Angular 2 provides. Note though, that the application we&#8217;re developing is really that complex, so I can only assume we&#8217;ll run into more complex Angular2 features in the near future. For now, though, let me share some general tips and tricks we&#8217;ve encountered thus far (in no particular order). Oh, all examples are in typescript, since after using that, I really don&#8217;t want to go back to plain old javascript (POJS?).<\/p>\n<h2>1. Pipes for formatting<\/h2>\n<p>If you need to format some output string, in the old Angular version you used Filters. In Angular 2, though, the name of filters have changed and they are now called pipes. Using pipes is very easy and only takes a couple of steps to get working. First, you need to define a pipe:<\/p>\n<pre class=\"brush:java\">import {Pipe} from '@angular\/core';\r\nimport {FormatUtils} from '..\/utils\/formatUtils';\r\n\u00a0\r\n@Pipe ({\r\n  name : \"humanReadableNumber\"\r\n})\r\nexport class HumanReadableNumber {\r\n\u00a0\r\n  transform(value: any) {\r\n    \/\/ converts a size to something human readable\r\n    return FormatUtils.humanSize(+value);\r\n  }\r\n}<\/pre>\n<p>Now that we&#8217;ve got a pipe we can import it in our component, and use it to format a value in our page. We import is like this, and add it to the <strong>pipes<\/strong> property of the<\/p>\n<pre class=\"brush:java\">import {Component} from '@angular\/core';\r\nimport {CORE_DIRECTIVES} from '@angular\/common';\r\nimport {HumanReadableNumber} from '..\/..\/..\/shared\/pipes\/humanReadablePipe'\r\n\u00a0\r\n@Component({\r\n\ttemplateUrl: 'some-template.html',\r\n  directives: [CORE_DIRECTIVES],\r\n  pipes: [HumanReadableNumber]\r\n})\r\nexport class SomeCmp {\r\n  ...\r\n}<\/pre>\n<p>And using it in our code is just as simple:<\/p>\n<pre class=\"brush:java\">&lt;div class=\"col-sm-3\"&gt;\r\n  &lt;span class=\"text-red\"&gt;{{failureCount | humanReadableNumber}}&lt;\/span&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>And the cool thing is you can chain pipes together, and of course also create parameterized pipes. The official documentation for pipes can be found here: <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/pipes.html\">https:\/\/angular.io\/docs\/ts\/latest\/guide\/pipes.html<\/a><\/p>\n<h2>2. HTTP is easy to use<\/h2>\n<p>You can&#8217;t have a web application without making some HTTP calls to pull in data. With Angular 2 this is suprisingly easy. Just inject the **http** component, pass in the headers and parameters, and you get back on observable. As soon as you subscribe to the observable, the call will be executed, and you can easily use the functions provides by rx.js to transform the response (see next tip):<\/p>\n<pre class=\"brush:java\">private getSomeData(timePeriod: TimePeriod): Observable&lt;any&gt; {\r\n\u00a0\r\n  let headers = new Headers();\r\n  headers.append('Content-Type', 'application\/json');\r\n\u00a0\r\n  \/\/ handle the today case differently, since we need to go to start of day\r\n  let [from, to] = (timePeriod.name === Configuration.timePeriod.today.name)\r\n    ? [moment().utc().hours(0), moment()]\r\n    : [moment().subtract(timePeriod.amount, timePeriod.period), moment()];\r\n\u00a0\r\n  \/\/ setup and add the query parameters\r\n  let params = new URLSearchParams();\r\n  params.set('environment', 'test');\r\n  params.set('interval', timePeriod.period);\r\n  params.set('from', from.toISOString());\r\n  params.set('to', to.toISOString());\r\n\u00a0\r\n  return this.http.get('http:\/\/the.url', { headers: this.getHeaders(), search: params })\r\n    .map((res: any) =&gt; res.json());\r\n}<\/pre>\n<p>And the result is an observable, which can be consumed like this:<\/p>\n<pre class=\"brush:java\">someService.getSomeData(period).subscribe((json: any) =&gt; ({\/\/ do something with the json}));<\/pre>\n<p>The official documentation for HTTP can be found here: <a href=\"https:\/\/angular.io\/docs\/ts\/latest\/guide\/server-communication.html\">https:\/\/angular.io\/docs\/ts\/latest\/guide\/server-communication.html<\/a><\/p>\n<h2>3. Observables are really cool<\/h2>\n<p>In Angular 1 when communicating over HTTP, or doing stuff asynchronously you would use promises. In Angular 2, promises have been replaced with Observables. Without going too deep into what Observables are, in short they provide a way to subscribe to a sequence of events and act whenever the observable emits a new event. The really cool thing is that you can apply all kinds of operations and transformations on the events before they are processed by a subscriber. You can for instance map it to a domain object, group multiple events together and much, much more (see the rx.js documentation for all the options: <a href=\"http:\/\/reactivex.io\/rxjs\/class\/es6\/Observable.js~Observable.html\">http:\/\/reactivex.io\/rxjs\/class\/es6\/Observable.js~Observable.html<\/a>)<\/p>\n<p>The easiest example of an Observable is when you want to do an HTTP request in Angular 2. Instead of working with promises you now do something like this:<\/p>\n<pre class=\"brush:java\">import {Http} from '@angular\/http';\r\nimport {Inject} from '@angular\/core';\r\nimport {Headers} from '@angular\/http';\r\n\u00a0\r\nexport class SomeService {\r\n\u00a0\r\n  constructor(@Inject(Http) private http: Http) {};\r\n\u00a0\r\n  getPerson() : Observable&lt;Person&gt; {\r\n    let headers = new Headers();\r\n    headers.append('Content-Type', 'application\/json');\r\n\u00a0\r\n    return this.http.get('http:\/\/the.url.endpoint', {headers})\r\n      .map(res =&gt; res.json())\r\n      .map(res =&gt; new Person(res.name, res.age));\r\n  }\r\n}<\/pre>\n<p>As you can see the result is an <strong>Observable<\/strong>. We can now use this Observable very simply like this:<\/p>\n<pre class=\"brush:java\">import {Component} from '@angular\/core';\r\nimport {Person} from '..\/shared\/domain';\r\nimport {SomeService} from 'some-service';\r\n\u00a0\r\n@Component({\r\n  templateUrl: 'someTemplate.html'\r\n})\r\nexport class AnotherCmp {\r\n\u00a0\r\n  public person: Person;\r\n\u00a0\r\n  constructor(private someService: SomeService) {\r\n    someService.getPerson().subscribe((person) =&gt; (this.person = person));\r\n  }\r\n}<\/pre>\n<p>We subscribe to the observable. When we do this, the HTTP call will be made, and when it returns, we just assign the response to a public variable. Another feature of Observables we use is to wait for multiple calls to finish, before sending the message to a subscriber. This uses the <strong>forkJoin<\/strong> function provided by rxjs.<\/p>\n<pre class=\"brush:java\">public getMonthlyInfo(): Observable&lt;MonthData[]&gt;  {\r\n  let observables: Observable&lt;MonthData&gt;[] = [];\r\n\u00a0\r\n  \/\/ create the observables for the different calls\r\n  \/\/ and add them to the observables array\r\n  ...\r\n\u00a0\r\n  \/\/ Intellij throws a false error: https:\/\/youtrack.jetbrains.com\/issue\/WEB-20992\r\n  \/\/ this returns another observable, which returns an array of results from the\r\n  \/\/ observables we passed in to the forkJoin\r\n  return Observable.forkJoin(observables);\r\n}<\/pre>\n<p>And this is just touching upon the surface of what is possible with Observables. On a side note, if you prefer to work with Promises, you can use the *toPromise* function on an observable to turn it into a promise.<\/p>\n<h2>4. Start with use angular2 seed<\/h2>\n<p>Maybe I should have added this as the first tip, but setting up a build environment using gulp systemJS (or webpack) can be a bit of an hassle. Luckily, though, there is an easy way to get started using angular seed. There are multiple angular seeds available, but I use this one: <a href=\"https:\/\/github.com\/mgechev\/angular2-seed\">https:\/\/github.com\/mgechev\/angular2-seed<\/a>. It provides a systemJS \/ gulp based seed setup, including all kinds of nice features. Getting started with it, is also very trivial:<\/p>\n<pre class=\"brush:java\">git clone --depth 1 https:\/\/github.com\/mgechev\/angular2-seed.git\r\ncd angular2-seed\r\n# install the project's dependencies\r\nnpm install\r\n# watches your files and uses livereload by default\r\nnpm start\r\n# api document for the app\r\nnpm run build.docs\r\n\u00a0\r\n# dev build\r\nnpm run build.dev\r\n# prod build\r\nnpm run build.prod<\/pre>\n<p>If you want to use it as the base for your own project, it might be good to run the following git commands after cloning the repository, to point it to your own repository \/ project:<\/p>\n<pre class=\"brush:java\">rm -rf .git\r\ngit init\r\ngit remote add origin https:\/\/giturl.of.your.project.git<\/pre>\n<h2>5. Intercept requests for authentication<\/h2>\n<p>One of the first things I wanted to add to our application was a way to check whether a user was logged in. I was looking for global filters, and stumbled upon this example: <a href=\"https:\/\/github.com\/auth0-blog\/angular2-authentication-sample\">https:\/\/github.com\/auth0-blog\/angular2-authentication-sample<\/a>. This shows how to use a <strong>RouterOutlet<\/strong> to check for certain conditions, before handling the request. Basically what you do is, you define a custom <strong>RouterOutlet<\/strong>:<\/p>\n<p>From (<a href=\"https:\/\/github.com\/auth0-blog\/angular2-authentication-sample\/blob\/master\/src\/app\/LoggedInOutlet.ts\">https:\/\/github.com\/auth0-blog\/angular2-authentication-sample\/blob\/master&#8230;<\/a>):<\/p>\n<pre class=\"brush:java\">import {Directive, Attribute, ViewContainerRef, DynamicComponentLoader} from '@angular\/core';\r\nimport {Router, RouterOutlet, ComponentInstruction} from '@angular\/router-deprecated';\r\nimport {Login} from '..\/login\/login';\r\n\u00a0\r\n@Directive({\r\n  selector: 'router-outlet'\r\n})\r\nexport class LoggedInRouterOutlet extends RouterOutlet {\r\n  publicRoutes: any;\r\n  private parentRouter: Router;\r\n\u00a0\r\n  constructor(_viewContainerRef: ViewContainerRef, _loader: DynamicComponentLoader,\r\n              _parentRouter: Router, @Attribute('name') nameAttr: string) {\r\n    super(_viewContainerRef, _loader, _parentRouter, nameAttr);\r\n\u00a0\r\n    this.parentRouter = _parentRouter;\r\n    \/\/ The Boolean following each route below\r\n    \/\/ denotes whether the route requires authentication to view\r\n    this.publicRoutes = {\r\n      'login': true,\r\n      'signup': true\r\n    };\r\n  }\r\n\u00a0\r\n  activate(instruction: ComponentInstruction) {\r\n    let url = instruction.urlPath;\r\n    if (!this.publicRoutes[url] &amp;&amp; !localStorage.getItem('jwt')) {\r\n      \/\/ todo: redirect to Login, may be there a better way?\r\n      this.parentRouter.navigateByUrl('\/login');\r\n    }\r\n    return super.activate(instruction);\r\n  }\r\n}<\/pre>\n<p>And this allows you to check certain conditions before normally processing the request, or passing it on. I can explain how it works here, but just look at the github repository which will do a much better job.<\/p>\n<h2>6. Directives are very easy to write<\/h2>\n<p>In Angular2 the distinction between controllers and directives is removed. A directive is just a simple component, where some of it&#8217;s values are populated when the component is instantiated. For instance a simple component that wraps one of the great <a href=\"https:\/\/github.com\/valor-software\/ng2-charts\">https:\/\/github.com\/valor-software\/ng2-charts<\/a> charts looks like this:<\/p>\n<pre class=\"brush:java\">import {Component, Input} from '@angular\/core';\r\nimport {CORE_DIRECTIVES} from '@angular\/common';\r\nimport {CHART_DIRECTIVES} from 'ng2-charts\/ng2-charts';\r\nimport {DecisionNodeSummary} from '..\/..\/..\/shared\/domain\/dagSummary';\r\n\u00a0\r\n@Component({\r\n  selector: 'dag-decnode-graph',\r\n  templateUrl: 'decisionnode-graph.html',\r\n  directives: [CHART_DIRECTIVES, CORE_DIRECTIVES]\r\n})\r\nexport class DagDecNodeGraph {\r\n\u00a0\r\n  public title = \"\";\r\n\u00a0\r\n  @Input()\r\n  set nodeSummary(nodeSummary: NodeSummary) {\r\n    this.routingStatusChartData = [nodeSummary.falsePath, nodeSummary.truePath];\r\n    this.title = nodeSummary.name;\r\n  };\r\n\u00a0\r\n  public routingStatusChartLabels: string[] = ['false', 'true'];\r\n  public routingStatusChartType: string = 'doughnut';\r\n  public routingStatusChartLegend: boolean = false;\r\n  public routingStatusChartData: number[] = [0, 0];\r\n  public routingStatusChartOptions: any = {};\r\n\u00a0\r\n  constructor() {\r\n  }\r\n\u00a0\r\n}<\/pre>\n<p>And the relevant template:<\/p>\n<pre class=\"brush:java\">&lt;div class=\"col-md-4\"&gt;\r\n  &lt;h4 style=\"text-align: center\"&gt;{{ title }}&lt;\/h4&gt;\r\n  &lt;base-chart class=\"chart\"\r\n              [data]=\"routingStatusChartData\"\r\n              [labels]=\"routingStatusChartLabels\"\r\n              [legend]=\"routingStatusChartLegend\"\r\n              [chartType]=\"routingStatusChartType\"&gt;&lt;\/base-chart&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Nevermind the model which is passed in, but this is basically all you need to do to define a directive. To use this directive in a page you just do something like this:<\/p>\n<pre class=\"brush:java\">&lt;div *ngFor='let node of nodes'&gt;&lt;dag-decnode-graph [nodeSummary]=\"node\"&gt;&lt;\/dag-decnode-graph&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>How easy is that! No more specific javascript, or custom functions. Just a simple component, just like all the other components.<\/p>\n<h2>7. Typescript: domain objects are cheap and easy, type everything.<\/h2>\n<p>I couldn&#8217;t write this, without at least mentioning typescrypt. I really like typescript I come from a Java and Scala background and am used to having compile-time typechecking (and using IDEs to autocomplete some stuff). With typescript this also becomes available to Angular, and it works really great. What makes it even better is that creating basic domain objects is really easy and quick:<\/p>\n<pre class=\"brush:java\">export class Person {\r\n  constructor(public name: number, public age: number) {}\r\n}<\/pre>\n<p>And you can easily access the public properties, and hide the private properties. It even support default values. It isn&#8217;t quite up to Scala case classes yet, but it is a great way of defined a good domain model in your frontend applications. This combined with the **map** function of the **Observable**, it is very easy and convient to use these domain objects throughout your application.<\/p>\n<h2>8. Use jquery<\/h2>\n<p>In many cases there isn&#8217;t a big need for jQuery in Angular projects. However, there is big ecosystem of great jQuery based components and libraries that will come in handy. While using jquery in Angular 2 isn&#8217;t that difficult, getting the typescript compiler to compile your code when including jquery in your dependencies might be harder. When you include jQuery you&#8217;ll quickly run into an error message something like this:<\/p>\n<pre class=\"brush:java\">Subsequent variable declarations must have the same type.  \r\nVariable '$' must be of type 'cssSelectorHelper', but here has type 'JQueryStatic'.\r\nWeb\\Scripts\\typings\\jquery\\jquery.d.ts   3936<\/pre>\n<p>Basically, there are two different libraries claiming the <strong>$<\/strong> name. This can be quickly solved by replacing the last couple of lines from the **jquery\/index.d.ts** to this:<\/p>\n<pre class=\"brush:java\">interface JQuery {\r\n    \/\/ add additional functions you might want to expose from other libraries\r\n    \/\/ that append the jquery object\r\n    chosen(options?:any):JQuery;\r\n    bootstrapTable(...options:any[]):JQuery;\r\n}\r\n\u00a0\r\ndeclare module \"jquery\" {\r\n    export = JQuery;\r\n}\r\ndeclare var jQuery: JQueryStatic;<\/pre>\n<p>Now you can use the jquery library like this in code:<\/p>\n<pre class=\"brush:java\">declare var jQuery:JQueryStatic;\r\n\u00a0\r\n...\r\n\/\/ do whatever you want, just use jQuery instead of $\r\njQuery('.elem')<\/pre>\n<p>While this works, you&#8217;ll notice that you have to repeat this process after each npm install or whenever you add a new library. Luckily you can override the typings that are retrieved when doing an **npm install**. So to permanently apply these settings, save the typings to a separate directory and change the jquery entry in the **typings.json** file to this:<\/p>\n<pre class=\"brush:java\">\"jquery\": \"file:overrides\/typings\/jquery\/index.d.ts\",<\/pre>\n<p>This points to our own custom jquery typings file in a separate directory. finally to get everything to work also update the tsconfig.json file to exclude this file or else you&#8217;ll get duplicate definitions errors:<\/p>\n<pre class=\"brush:java\">\"exclude\": [\r\n  \"node_modules\",\r\n  \"dist\",\r\n  \"typings\/browser.d.ts\",\r\n  \"typings\/browser\",\r\n  \"src\",\r\n  \"overrides\"\r\n]<\/pre>\n<h2>Conclusions<\/h2>\n<p>This is just a quick set of observations from a couple of days intensive Angular 2 development. My main conclusion, though, it that it really is fun doing frontend development with Angular 2. It might because of typescript, but so far it feels like a really great, well thought out framework. It just works and a lot of the annoying things from Angular 1 have been solved.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/www.smartjava.org\/content\/first-steps-angular-2-8-cool-features\">First steps with Angular 2: 8 cool features<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Jos Dirksen at the <a href=\"http:\/\/www.smartjava.org\/\">Smart Java<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really natural and straightforward while working with it. No more string based dependency injection, or strange digest cycle stuff, it just seems to work. This last week I&#8217;ve &hellip;<\/p>\n","protected":false},"author":11,"featured_media":909,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-12906","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>First steps with Angular 2: 8 cool features - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"I&#039;ve been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"First steps with Angular 2: 8 cool features - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-01T09:15:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jos Dirksen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jos Dirksen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\"},\"author\":{\"name\":\"Jos Dirksen\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/85292631fddd881f88ab3b10d8257505\"},\"headline\":\"First steps with Angular 2: 8 cool features\",\"datePublished\":\"2016-06-01T09:15:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\"},\"wordCount\":1456,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"articleSection\":[\"Angular.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\",\"name\":\"First steps with Angular 2: 8 cool features - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"datePublished\":\"2016-06-01T09:15:30+00:00\",\"description\":\"I've been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"First steps with Angular 2: 8 cool features\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/85292631fddd881f88ab3b10d8257505\",\"name\":\"Jos Dirksen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bc7ecab0b9c4dcc3d53ae3554532370b976da88a8e2421d8148b06da11bb13e0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bc7ecab0b9c4dcc3d53ae3554532370b976da88a8e2421d8148b06da11bb13e0?s=96&d=mm&r=g\",\"caption\":\"Jos Dirksen\"},\"sameAs\":[\"http:\/\/www.smartjava.org\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/jos-dirksen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"First steps with Angular 2: 8 cool features - Web Code Geeks - 2026","description":"I've been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/","og_locale":"en_US","og_type":"article","og_title":"First steps with Angular 2: 8 cool features - Web Code Geeks - 2026","og_description":"I've been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-06-01T09:15:30+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","type":"image\/jpeg"}],"author":"Jos Dirksen","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Jos Dirksen","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/"},"author":{"name":"Jos Dirksen","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/85292631fddd881f88ab3b10d8257505"},"headline":"First steps with Angular 2: 8 cool features","datePublished":"2016-06-01T09:15:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/"},"wordCount":1456,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","articleSection":["Angular.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/","name":"First steps with Angular 2: 8 cool features - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","datePublished":"2016-06-01T09:15:30+00:00","description":"I've been doing some work the last couple of weeks with Angular2. I really like it. Not just because it uses typescript, but also because it feels really","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/first-steps-angular-2-8-cool-features\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Angular.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/"},{"@type":"ListItem","position":4,"name":"First steps with Angular 2: 8 cool features"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/85292631fddd881f88ab3b10d8257505","name":"Jos Dirksen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/bc7ecab0b9c4dcc3d53ae3554532370b976da88a8e2421d8148b06da11bb13e0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bc7ecab0b9c4dcc3d53ae3554532370b976da88a8e2421d8148b06da11bb13e0?s=96&d=mm&r=g","caption":"Jos Dirksen"},"sameAs":["http:\/\/www.smartjava.org\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/jos-dirksen\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/12906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=12906"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/12906\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/909"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=12906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=12906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=12906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}