Devtech

Talk about technologies

Angular 2 HTTP Requests and Observables

     Observables are basically the ES7(2016) feature implemented in Rxjs library.i.e. Reactive Extensions for the JavaScript. We use observables in Angular 2 by importing it from the rxjs library. Angular 2 provides such a wonderful features that makes application development a charm. We are going to learn how to make HTTP Requests in Angular 2 using Rxjs Observable library. Little Bit About Angular 2 Observables      Observable are similar to the Promises in AngularJS but with some differences. Observables handle multiple values over the time, while Promise return only single value. Observables can be cancelled, while the Promises not. Lets talk about the case, Suppose we are implementing the Autocomplete feature. on each key press event we supposed to send the requests to fetch the results. On typing Observable, the results of key ‘O’ will come after ‘ob’, then it will make the result set very messy, we may want to cancel the requests of key ‘o’. So here Observables shines. Observables comes with many operators, most of popular are map, filter, etc. I am using Map in this tutorial. Observable makes […]

Angular 2 Forms and Validations

We use forms to take user input. In past times, Form handling was seems to be difficult task, mainly how valid is the user input. Nested if else statements even makes it tedious to built. Result is inconsistent, unmanageable, unpredictable results. Now Angular 2 makes easy to build, manage the forms, and take input from the user. Angular 2 makes it really easy to take user input, track changes, validate and show errors. So lets have a look what are Angular 2 forms. Angular 2.x have two types of forms:- Template Driven Forms Model Driven Forms( also known as Reactive forms ) Template Driven Forms This is not so different from as we used to do in the past to build forms in simple UI (HTML). These are basically simple HTML forms that are used to take input from the user. Model Driven or Reactive Forms Model Driven forms are simple forms similar to the Template Driven forms, difference is we have to declare the model of the form in the Component Class. This way we have more controls over […]

Show Buttons
Hide Buttons