Why to use Angular 2?
*] easier to understand.
*] minimal memory overhead
*] minimal memory overhead
angular 2 : Features
-> faster and easier than Angularjs 1.
-> focused on mainly mobile apps
-> Source Code structure is very easy tosimplified
-> 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 ng4free
->cd ng4free
->cd ng4free
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": "ng4free",
"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
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
<!DOCTYPE html>
<html>
<head>
<title>my angular2 First Application : Hello World</title>
<script>
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));
</script>
</head>
<body>
<my-app>Simple Loading.......</my-app>
<hr/>
<h1>Solution of AngularJs All Problems For ng4free.com</h1>
<h3>
<a href="http://ng4free.com/" alt="Link of angularjs Solution example and demo">My First Web-Application in angularjs, So I am very happy and 1000+ more then people are used of ng4free.com </a>
</h3>
</body>
</html>
Step 10 : run your application
-> npm start


0 comments: