Skip to main content

IMPORTANT




Following are the key features of Angular 2 

  1. Components 
  2. TypeScript 
  3. Services 
  4. event-handling capabilities
  5. powerful templates,
  6. better support for mobile devices.

  • Modules : Breaks  application into logical pieces of code. 
  • Component: Bring the modules together.
  • TemplatesDefine the views of an Angular JS application.
  • Metadata: Add more data to an Angular JS class.
  • Service :Create components which can be shared across the entire application.


MODULE 

import { NgModule }      from '@angular/core'; --> IMPORTS FNLTY OF OTHER MODULES
import { BrowserModule } from '@angular/platform-browser';  
import { AppComponent }  from './app.component';  

@NgModule ({ -----> THIS IS DECORATOR
   imports:      [ BrowserModule ],//required by web based application 
   declarations: [ AppComponent ], 
   bootstrap:    [ AppComponent ] //Which component to bootstrap in application
}) 
export class AppModule { } 

  • The NgModule decorator is used to later on define the imports, declarations, and bootstrapping options.
A MODULE CONSISTS OF 

A module is made up of the following parts −
  • Bootstrap array − This is used to tell Angular JS which components need to be loaded so that its functionality can be accessed in the application. Once you include the component in the bootstrap array, you need to declare them so that they can be used across other components in the Angular JS application.
  • Export array − This is used to export components, directives, and pipes which can then be used in other modules.
  • Import array − Just like the export array, the import array can be used to import the functionality from other Angular JS modules.

A component consists of −
  • Class − This is like a class defined in any language such as C. This contains properties and methods. This has the code which is used to support the view. It is defined in TypeScript.
  • class classname {
       Propertyname: PropertyType = Value
    }
  • Metadata − This is used to decorate the class and extend the functionality of the class.
  •  Template − This is used to render the view for the application. This contains the HTML that needs to be rendered in the application. This part also includes the binding and directives.
template: '
   

{{appTitle}}

To Tutorials Point
'
Component
Following is an example of a component.
import { Component } from '@angular/core';

@Component ({ 
   selector: 'my-app', 
   templateUrl: 'app/app.component.html' 
}) 

export class AppComponent { 
   appTitle: string = 'Welcome';
} 
Each application will have a root angular module & others are imported in it.


Following is an example of a root module.

import { NgModule }      from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { AppComponent }  from './app.component';  

@NgModule ({ 
   imports:      [ BrowserModule ], 
   declarations: [ AppComponent ], 
   bootstrap:    [ AppComponent ] 
}) 
export class AppModule { } 



Following is an example of a component.

import { Component } from '@angular/core';

@Component ({ 
   selector: 'my-app', 
   templateUrl: 'app/app.component.html' 
}) 

export class AppComponent { 
   appTitle: string = 'Welcome';
} 


import { Component } from '@angular/core';

@Component ({
   selector: 'my-app',
   templateUrl: 'app/app.component.html'  
})

export class AppComponent {
   appTitle: string = 'Welcome';
}


*ng-if

import { Component } from '@angular/core';  

@Component ({
   selector: 'my-app',
   templateUrl: 'app/app.component.html'
})

export class AppComponent {
   appTitle: string = 'Welcome';
   appStatus: boolean = true;
}
{{appTitle}} Tutorialspoint

*ng-for


import { Component } from '@angular/core';
 
@Component ({
   selector: 'my-app',
   templateUrl: 'app/app.component.html'
})

export class AppComponent {
   appTitle: string = 'Welcome';
   appList: any[] = [ {
      "ID": "1",
      "Name" : "One"
   },

   {
      "ID": "2",
      "Name" : "Two"
   } ];
}
*ngFor = 'let lst of appList'>
  • {{lst.ID}}
  • {{lst.Name}}

    Metadata is used to decorate a class so that it can configure the expected behavior of the class.

    These are decorators at the class level. This is an array and an example having both the @Component and @Routes decorator


    DATA BINIDNG 

    export class className {
       property: propertytype = value;
    }

















    Comments

    Popular posts from this blog

    Microservices Design patterns

    What are microservices? Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are Highly maintainable and testable Loosely coupled Independently deployable Organized around business capabilities Owned by a small team The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications. It also enables an organization to evolve its technology stack. You are developing a server-side enterprise application. It must support a variety of different clients including desktop browsers, mobile browsers and native mobile applications. The application might also expose an API for 3rd parties to consume. It might also integrate with other applications via either web services or a message broker. The application handles requests (HTTP requests and messages) by executing business logic; accessing a database; exchanging messages with other systems; and returni...

    GraphQL

    What is GraphQL  API Standard invented & open-sourced by Facebook Alternative to  REST API  enables declarative data fetching  exposes single endpoint & responds to queries How it works?  Why Graphql? Improvises performance by reducing the data that is to be transferred over the internet Variety of different frontend frameworks and platforms on client-side Fast development speed & expectation for rapid feature development Why Graphql is better than REST? Flexibility & efficient  No more over /under fetching of data Over fetching : Under fetching: Insightful analytics  Schema serves as contract between client and server CORE CONCEPTS : SDL :SCHEMA DEFINITION LANGUAGE Writing Data with mutations 3 kinds of mutations creating new data updating existing data deleting existing data

    Jackson

    <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-core </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-annotations </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-databind </artifactId> <version>2.9.6</version> </dependency> CBOR encoded data with Jackson <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-cbor</artifactId> <version>2.9.6</version> </dependency> In order to read and write MessagePack encoded data <dependency> <groupId>org.msgpack</groupId> <artifactId>jackson-dataformat-msgp...