Home » Archive by category "Angular 2" (Page 2)

Reasons to use RxJS Today

If you’ve started looking at Angular 2, one of the things that you’ll notice is that RxJS has gotten a bit of a toe hold in the framework.  This becomes apparent the first time you try to access data.  Gone is the $http service that returns a promise.  Instead, we now have a service that returns an Observable.

Now, writing the code to access the server is arguably easy to learn.  But, as you travel down the rabbit hole that is Angular 2, you realize that RxJS shows up in places as disperse as NgRX/Store, handling events, and as we’ve already mentioned, AJAX calls.

Because it shows up in so many places, this new API is set to be the next thing we will need to learn to be effective JavaScript programmers.  But, should we?

Reasons to use RxJS Today
Photo credit: Dace Kiršpile via Visualhunt / CC BY

Continue reading “Reasons to use RxJS Today”

Adding Client Side Routing to Angular 2

Over the last several Angular 2 posts, we’ve been building up our application bit by bit and examining the various features of Angular 2 along the way using the Angular CLI where that makes sense and modifying it along the way.  So far, routing is an area that the Angular CLI does not yet support and so, when you want to use routing in your Angular 2 application, you’ll need to wire most of it in by hand.

Now, the routing engine has changed several times during the development of Angular 2.  And I know you’re wondering which version of the router this article is going to be talking about.  So, to be clear, this article was written using the Angular CLI version 1.0.0-beta.21 and Router version 3.2.1.

Adding Client Side Routing to Angular 2
Photo credit: xomiele via Visualhunt / CC BY

Continue reading “Adding Client Side Routing to Angular 2”

Unit Testing an Angular 2 CLI Project

This week we want to continue our series about Angular 2 by looking at the Unit Testing capabilities that Angular 2 provides for us.  What we want to cover today is:

  • Tweaking Karma to avoid using the Browser Window
  • Code Coverage
  • Tips to testing components

This article was written using Angular CLI version 1.0.0-beta.20-4  (Tip, if you are upgrading on windows, rm –rf node_modules dist temp just means to delete the three directories.  You can do that part manually, or install bash for Windows and run the command in bash.)

Unit Testing an Angular 2 CLI Project
Photo credit: jimmiehomeschoolmom via VisualHunt.com / CC BY-NC-SA

Continue reading “Unit Testing an Angular 2 CLI Project”