Posts

Showing posts with the label angular2

Subject in Angular 2

Image
Hello all, Here I am with my second piece of writing on JavaScript solutions to common problems. In this article we will look at Subject in Angular and its comparison with EventEmitter . First lets know what Subject is? Subject is an Observable. But an Observable only allows you to subscribe to an event whereas subject allows you to both publish and subscribe to an event. So Subject allows your service to be used as both a publisher and subscriber. Question: Now a Question always arise that why should we use Subject instead of EventEmitter provided by Angular itself whereas Subject is part rxjs package which is a third party provider. In my opinion EventEmitter is expected to emit events between components or directives. As per  EventEmitter Documentation  which says: use by directives and components to emit custom events .  Eventhough you can use it as you want, but I think you will be misusing it. So using  ...

Google maps places autocomplete using Angular 2

Image
Hello all, Entering location manually could be the most annoying part any user can experience while using your application. Maps Places autocomplete feature could be added to any particular application written in any specific language. Here we will do it using angular 2. Angular or Angular 2/4  the latest buzz in the Javascript world is considered the best amongst many Javascript frameworks. Before we proceed we need an angular project which we will create using angular cli. Angular CLI You all can refer to this  Angular CLI . npm install  @angular/cli -g ng new my-app cd my-app ng serve note: MAC users should use npm install with administrative permissions (use sudo before command). Now we need a package for using google maps components to achieve what we started on. Angular Google Maps(AGM) Angular Google Maps(AGM) contains serveral components to use google maps and its several components into your applications. We use it by installing packages to ou...