Run Custom Functionality When Angular Http Errors Occur

Angular includes its own functionality for making HTTP requests. When using it, you may want to react to any errors that happen – perhaps to display an on-screen error message. You can achieve that by extending Http. custom-http.service.ts import { Injectable } from '@angular/core'; import { ConnectionBackend, Http, Request, RequestOptions,... [Read More]
Tags: angular

Comparing Angular NgModule and TestBed Side by Side

TestBed’s configureTestingModule method looks similar to NgModule in usage. Check out this side by side example: @NgModule({ | TestBed.configureTestingModule({ | declarations:[ | declarations: [ AppComponent, | AppComponent, CurrentResultsComponent, | CurrentResultsComponent, ResultsLogComponent | ResultsLogComponent ], | ], imports: [ | imports: [ BrowserModule, | FormsModule, FormsModule, | HttpModule HttpModule | ],... [Read More]
Tags: angular

2016: Personal Highlights

I posted a personal recap last year, and the year before that. For this year, I’m calling it “2016: Personal Highlights”: I received my first Microsoft MVP award in Visual Studio and Development Technologies. It’s awesome to be recognized for my efforts! I spoke at my first international conference this... [Read More]
Tags: 2016, highlights

Subscribing to Browser Title Changes Using Angular

Angular includes a Title service, which includes getTitle(): string and setTitle(newTitle: string). If you want to keep an in-page header matching the browser title tag, you’ll need something to enable that possibility. If you like the pattern of subscribing to changes (as you might be, if you’re using Angular), check... [Read More]
Tags: angular

Angular 2 Services Testing Template

Here’s a simple template for testing Angular 2 services. If the HttpModule portions are uncommented and used, it will make actual wire calls. To use mock calls instead, see Angular 2 MockBackend Service Testing Template Using TestBed instead. import { async, inject, TestBed } from '@angular/core/testing'; // import { HttpModule... [Read More]
Tags: angular, testing