Tuesday, January 31, 2017

Overview of Express (Web framework)



  • Fast opinionated, minimalist web framework for node.js
  • Provides thin layer of fundamental web application features,without obscuring Node features
  • Provides robust set of features for web and mobile applications
  • Built inside node.js
  • Its a npm package

Event Loop in Node



  • Nodes event loop is constantly listening for events on the server side. 
  • These events can be externally generated such as http request or tcp connections
  • Other events may be triggered on the response to a request against external resource
    • ex asking node for file for reading
  • Each events are handled as discrete events


Building blocks for Node



libuv :

  • A high performance cross platform evented i/o library
  • Replaces or abstracts several unix only library that is required by the project
  • Built as a part of porting js to windows

Saturday, January 28, 2017

Exception handling in angular 2

  1. we need to use "catch" operator
  2. Pass it to error handling method
  3. The error handling method has only  one parameter the error response                                      
  4. In this message we can handle errors appropriately

Wednesday, January 25, 2017

Improving angular 2 components


Strong typing 

  • Benefits of using typescript is its strong typing.Every property has a type, every method has a return type, every method parameter has a type
  • Strong typing helps minimize errors through better syntax checking
  • If we do not have a pre defined type then we can use any [ ]

Bootstrap table using angular 2


We can display an html table as a grid using bootstrap css class.

Strongly typed Angular 2 components



Typescript, is a typed superset of the JavaScript language that is compiled to produce clean, simple cross-browser compatible JavaScript code, which can help when building and maintaining large-scale applications. Typescript has features of ES6 such as interfaces, classes and modules.


Note: To specify custom typing we can use an interface
In this example we have specified custom type for address using an interface.

Conditional statements in angular 2



  • { * } marks the directive as the structural directive
  • BrowserModule exposes ng-if and ng-for directives

Simple Angular 2 toggle function



Angular's *ngIf directive is not subject to style specificity constraints.  It's always safe to use regardless of your stylesheet.   However, it's worth noting that it's not functionally equivalent.  Rather than toggling the display property, it works by adding and removing template elements from the DOM.

Handling unique component style in angular 2 (CSS)


We have 2 options styles and stylesUrls . Both styles and stylesUrls can be used within

Simple angular 2 template


 In this example we have a component named as UserComponent.
 In the selector we need to specify the name of the view specified in index.html

Aanatomy of angular 2

Structure of Angular 2 application 


Relative paths with module Id in angular 2


We can specify absolute path directly in angular 2 as shown below


import {Component, OnInit} from '@angular/core';
//Import interface
import {IProduct} from './product';
//view for the component
@Component({
    selector:'pm-products',
    templateUrl:'app/products/product-list.component.html',
    styleUrls: ['app/products/product-list.component.css']

})

There are several downsides of using absolute path.
  • Harder to adjust folder structure.
  • Reuse the components
  • Some tools within angular require relative path

Angular 2 life cycle


Tuesday, January 24, 2017

Why angular and angular 2?








Looping in Angular 2 using *ngFor directive

The NgFor directive instantiates a template once per item from an iterable.

In Es 2015 we have  "for..of " : loops through the properties of the array
and "for..in"  :loops through the index of the array.



let keyword creates a template input variable

Hide files in vs code



We can easily hide files in vscode .
  1. Click on file--> preferences --> work space settings
  2. Place your settings in settings.json
       

Scala in a nutshell


           
  • Functional programming language.Functions are first-class objects. Compose them with guaranteed type safety. Use them anywhere, pass them to anything.
  • Built for scalability. Scala is an acronym for “Scalable Language”.
  • Scala runs on the JVM, so Java and Scala stacks can be freely mixed for totally seamless integration
  • Language which can be used with Apache spark
  • Don’t work for the type system. Let the type system work for you

About Big data


        
                                   


       BigData

    • Term used to describe large volume of data.Both structured and unstructured data that include a business on day to day basis.
    • Can be analyzed for insights that lead to better decisions and strategic business moves.
    • Is in existence from many years. Due to cheap hardware and open source solution to the problem and communities it is getting popular
   

Data binding in angular 2



  Data binding is done to coordinate communication between a component and its template . 
  There are  four types of data binding



Overview of System js


       

  •    Universal dynamic module loader
  •    We do not have to reference our module using script reference.
  •    Less memory footprint

Monday, January 23, 2017

Anatomy of web request in angular 2


  1. When a user access our web application the first file that is downloaded is index.html
  2. Index.html has the link and our script tag that our module loader hosts our application. This would be the entry point of our application
   

Map files in angular 2

These are source maps that are generated by the compiler that helps to debug typescript code.
Many debuggers (e.g. Visual Studio or Chrome's dev tools) consume these files so you can debug the TypeScript file instead of the JavaScript file.


Modules in Angular 2

In java script we have problem with namespaces and also with code organization.
Modules provide a solution for this problem.They enable us to decouple our code easier.


Labels