Important update: RxJS 5.5 brought us Pipeable Operators that eliminate some of the problems noted below. If you can update to TypeScript 2.4, RxJS 5.5, Angular 5 and Angular CLI 1.5, you should definitely go with Pipeable Operators.
Angular has some third-party dependencies, one of which is RxJS, a library which makes reactive programming very easy to use. The library is obtained as an npm package. In order to use functionality from the RxJS library, it has to be imported first. So before you can use an operator such as map in the following snippet, it has to be imported:
Whereas IDEs such as WebStorm (prior to 2017.2) or Visual Studio Code do a good job for auto-importing symbols, they don’t suggest anything at all for RxJS symbols. Both IDEs simply print the following error message from TypeScript:
Property ‘map’ does not exist on type ‘Observable’.
This transpiler flag enables us to write safer code. TypeScript with strict null checking enabled feels even more comfortable for developers with a static-typed language background. Without strict null checking, assigning null or undefined for instance to a variable of type number is perfectly possible:
Testability is an important discipline in application development. Angular was always built with testability in mind. Protractor is Angular’s end-to-end testing framework. It was originally created for AngularJS, the first edition of the popular SPA framework, but works perfectly with Angular 2 by simply setting useAllAngular2AppRoots to truein Protractor’s config.js. In addition, you can optionally specify an element name for the rootElement property to exclusively test against this element.
Detecting clicks on a component is easy in Angular 2: Just use the (click) event binding, pass a function from the component’s instance and you are done. However, if you need to detect clicks outside of your component, things are getting tricky. You will usually need this for custom implementations of drop-down lists, context menus, pop-ups or widgets.
As this is a functionality which you might use more often, you should wrap it in a reusable directive. Angular 2 offers a syntactically nice way to implement such a directive. So let’s go ahead and implement a simple click-outside directive in Angular 2!
tl;dr: Implementing this directive is super easy. If you feel lazy, just run npm i angular2-click-outside.
Angular 2 is the next version of Google’s popular SPA framework. If you’re not yet familiar with it, you can find an overview here. In this article, I will focus on the dependencies of Angular 2. Whereas AngularJS (1.x) could either be run stand-alone or on top of jQuery, Angular 2 requires some third-party dependencies, which we’ll take a look at in this article:
Angular 2 is the upcoming all-new Single-Page Web Application (SPA) framework from Google. It’s the successor to the well-known AngularJS, which was first published in 2009.
Do you remember? In 2009, Windows 7 was released, which included Internet Explorer 8 as the default browser. The work on HTML5 just started. And the iPad wasn’t even on the market. Since then, the world and the web have changed a lot: Mobile internet usage surpassed desktop usage. Fully-fledged business applications are built using HTML5. And web technologies are on par with their native counterparts in terms of functionality and performance. Angular 2 wants to address these changes by being:
Note: This post was written during Angular’s beta phase. The issue is fixed in later versions of Angular 2.
Starting from Beta 1, Angular 2 applications don’t seem to run in Internet Explorer anymore—although Angular 2 officially supports Internet Explorer versions 9 to 11 and it worked like a charm in Beta 0. This is due to missing ECMAScript 2015 (ES6) shims which es6-shim doesn’t include. This can be easily solved by adding the missing shims which are buried deep in Angular’s package.