Skip to main content

Posts

Showing posts with the label Angular 2 async pipe with ngFor loop

What are Types in TypeScript?

What are TypeScript Types? The Type represents the different types of values which are using in the programming languages and it checks the validity of the supplied values before they are manipulated by your programs. Stayed Informed – Learn Angular 2 The TypeScript provides data types as a part of its optional type and its provide us some primitive types as well as a dynamic type “any” and this “any” work like “dynamic”. In TypeScript, we define a variable with a “type” and appending the “variable name” with “colon” followed by the type name i.e. let isActive: boolean = false ; OR var isActive: boolean = false ; let decimal: number = 6 ; OR var decimal: number = 6 ; let hex: number = 0xf00d ; OR var hex: number = 0xf00d ; let name: string = "Anil Singh" ; OR var name: string = "Anil Singh" ; let binary: number = 0 b1010; OR var binary: number = 0 b1010; let octal: number = 0 o744; OR var octal: number = 0 o7...

Why should I use Typescript ?

What is TypeScript? TypeScript is a strongly typed, object oriented and compiled language and this language developed and maintained by Microsoft. It was designed by “Anders Hejlsberg” at Microsoft. It is a superset of JavaScript.  The TypeScript is JavaScript and also has some additional features like static typing and class-based object-oriented programming, automatic assignment of constructor parameters and assigned null values and so on. Stayed Informed – Learn Angular 2 Why should I use Typescript?  What are the Benefits of Using TypeScript? 1.      Supports Object Oriented Programming. 2.      Typescript adds static typing to JavaScript. Having static typing makes easier to develop and maintain complex apps. 3.      Angular2 uses TypeScript a lot to simplify relations between various components and how the framework is built in general. 4.      Provide an optional...

Angular 2 promise vs observable

Both promise & observable help us to asynchronous requests callback. The important differences are: Promise Angular 2 promises handle a single callback when an async requests callback completes or fails. Observable Angular 2 provides a new pattern for running asynchronous requests, called Observables. Angular 2 uses an analogous pattern called Observables. The Observable classes in Angular 2 are provided by the ReactiveX library. Angular 2 observable allows passing zero or more events where the callback is called for each event. Observable provides operators like map , forEach etc. Reference link. https://egghead.io/lessons/rxjs-rxjs-observables-vs-promises

Angular 2 async pipe with ngFor loop

According to Angular 2 docs , “ Angular pipes, a way to write display-value transformations that we can declare in our HTML! ” Angular 2 templates use a special Async pipe to be able to render out Observables. Syntax:   *ngFor= "#obj of asyncObject | async | custom-Pipe: 'prop1' : 'prop2'" OR *ngFor= "#obj of (asyncObject | async)? .prop1? .prop2" For more detail, https://angular.io/docs/ts/latest/guide/pipes.html https://egghead.io/lessons/angular-2-rendering-an-observable-with-the-async-pipe