(Update) Finding current URL with Angular 2.0 Routing

23 בJune 2016

Previously I’ve posted about finding current URL with Angular 2.0 Routing which was suitable for rc-1. On Angular 2.0 rc-3, the angular router (alpha 3.0.0) has been added to the repository with much easierAPI for getting the current URL. Let’s have a look at the following code (Typescript) 1: constructor(private _router:Router){ 2: 3: } 4:  5: ngOnInit():any { 6: this._router.subscribe(event => { 7:...
no comments

Angular 2.0 Http client quick tip for firefox

14 בJune 2016

  When getting HTTP response from a REST API using Angular 2.0 HTTP client you will probably won’t mess around with your request headers. You’ll probably count on the service to return a JSON formatted response,  subscribeto this response and go ahead using it’s .json()  method which will use JSON.parse of your browser API.   However, while this solution works fine using chrome,  Firefox behave differently. While in chrome, the HTTP Accept headers will be */* , on Firefox it will put text/html,application/xhtml+xmlwhich basically will cause your server side to return its response in XML form.   Therefore...
one comment

Finding current URL with Angular 2.0 Routing

7 בJune 2016

  For an application built with AngularJs 2.0 (rc1) I wanted to do one simple thing: To highlightthe current active navigation  bar item. However, I’ve had to do it with the new angular router, the one that currently lacks documentation. So after a few searches online and digging through the router object I’ve reached the solution I want to share.   Let’s start with the solution itself: (Taken from the application’s entry component) 1: constructor(private router:Router){ 2: router.changes.subscribe(route =>{ 3: ...