Angular 2 Installation CLI setup environment

Angular 2 Installation CLI setup environment

Today, We want to share with you Angular 2 Installation CLI setup environment.
In this post we will show you Angular 2 installation step by step Javascript Example, hear for Angular 2 or Angular Local Development Environment Setup we will give you demo and example for implement.
In this post, we will learn about Setting Up Your First Angular 2 Project with an example.

Why to use Angular 2?

*] easier to understand.
*] minimal memory overhead

angular 2 : Features

faster and easier than Angularjs 1.

focused on mainly mobile apps

Source Code structure is very easy tosimplified

Simple Hello World Example : step By Step

Step 1 : create a directory/folder

mkdir infinityknow

READ :  jQuery Ajax Live Editable Table Records using PHP MySQLi

cd infinityknow

step 2 : Creating Configuration Files

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

step 3 : create a file : typings.json

typings.json

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160621231320"
  }
}

step 4 :create a file : package.json

package.json

{
  "name": "infinityknow",
  "version": "1.0.0",
  "scripts": {
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.7",
    "systemjs": "0.19.22",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.7.5",
    "typings":"^0.6.8"
  }
}

step 5 : command prompt to run

-> npm install

READ :  C# Anonymous Types Tutorial with Examples

step 6 : Creating Our First Angular Component

mkdir app
cd app

step 7: create a file app/environment_app.component.ts

import {Component, View} from "angular2/core";
@Component({
   selector: 'my-app'
})
@View({
  template: '<h2>My First Angular 2 App</h2>'
})
export class AppComponent {
}

step 8 : create a file : environment_main.ts

environment_main.ts

import {bootstrap} from "angular2/platform/browser"
import {AppComponent} from "./environment_app.component"
bootstrap(AppComponent);

step 9 : create a main file : index.html

index.html


  
    <title>my angular2 First Application : Hello World</title>
    <a href="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js">https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js</a>
    <a href="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js">https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js</a>
    <a href="https://code.angularjs.org/2.0.0-beta.6/angular2-polyfills.js">https://code.angularjs.org/2.0.0-beta.6/angular2-polyfills.js</a>
    <a href="https://code.angularjs.org/tools/system.js">https://code.angularjs.org/tools/system.js</a>
    <a href="https://code.angularjs.org/tools/typescript.js">https://code.angularjs.org/tools/typescript.js</a>
    <a href="https://code.angularjs.org/2.0.0-beta.6/Rx.js">https://code.angularjs.org/2.0.0-beta.6/Rx.js</a>
    <a href="https://code.angularjs.org/2.0.0-beta.6/angular2.dev.js">https://code.angularjs.org/2.0.0-beta.6/angular2.dev.js</a>
    
      System.config({
        transpiler: 'typescript',
        typescriptOptions: { emitDecoratorMetadata: true },
        packages: {'app': {defaultExtension: 'ts'}},
        map: { 'app': './angular2/src/app' }
      });
      System.import('app/environment_main')
            .then(null, console.error.bind(console));
    
  

   Simple Loading.......
 <hr />
<h1>Solution of AngularJs All Problems For infinityknow.com</h1>
<h3>
<a href="https://infinityknow.com/">My First Web-Application in angularjs, So I am very happy and 1000+  more then people are used of infinityknow.com </a>
</h3>


Step 10 : run your application

npm start

READ :  Angular Date filtering and formatting JSON Data

Add a Comment

Your email address will not be published. Required fields are marked *