Angularjs tutorial – Set up Angularjs 2 application

1. Create an application folder
2. Create the tsconfig.json file

{
  "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"
  ]
}

3. Create the package.json file

{
    "name": "Angular 2 Demo",
    "version": "1.0.0",
    "author": "Sandy Zhang",
    "description": "sample application",
    "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.9",
        "systemjs": "0.19.24",
        "es6-promise": "^3.0.2",
        "es6-shim": "^0.35.0",
        "reflect-metadata": "0.1.2",
        "rxjs": "5.0.0-beta.2",
        "zone.js": "0.5.15",
        "bootstrap": "^3.3.6"
    },
    "devDependencies": {
        "concurrently": "^2.0.0",
        "lite-server": "^2.1.0",
        "typescript": "^1.8.9",
        "typings": "^0.7.9"
    },
    "repository": {}
}

4. Create the typings.json file

{
  "ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"  }
}

5. Install the libraries and typings

 npm install

6. Create the host Web page (index.html)

angularjs2_index

7. Create the main.ts file (bootstrapper)

import { bootstrap } from 'angular2/platform/browser';

// Our main component
import { AppComponent } from './app.component';

bootstrap(AppComponent);

8. here is the AppComponent

import { Component } from 'angular2/core';
@Component({
    selector: 'sz-app',
    template: `

hello world!

` }) export class AppComponent { pageTitle: string = 'Hello world'; }
angularjs2_01
angularjs2_01
Advertisements

One thought on “Angularjs tutorial – Set up Angularjs 2 application”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s