Following is the app and files structure:
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component'
bootstrap(AppComponent);
Following code could be placed within package.json. Note that this is used to install node dependencies which would be used to load angular apps. Following dependencies are installed:
Following is the code sample for package.json.
{
"name": "ng2-apps",
"version": "1.0.0",
"scripts": {
"postinstall": "npm run typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
"typings" : "typings"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.6",
"systemjs": "0.19.20",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.14"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^2.0.1",
"typescript": "^1.7.5",
"typings":"^0.6.8"
}
}
Following is the code sample for tsconfig.json. It consists of configuration which is used by TypeScript compiler, tsc, to compile ts files and generate js files. Details on tsconfig.json could be obtained from Typescript WIKI page.
{
"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"
]
}
Following is the code sample for typings.json. Javascript libraries such as JQuery, Angular etc add JS syntax and features which Typescript compiler does not understand. This is where typings utility is used. It uses typings.json configuration to install TypeScript definitions appropriately.
{
"ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
}
}
Once the above three files (package.json, tsconfig.json, typings.json) are created within folder such as ng2-apps (hypthetical), execute the command “npm install” and you woudl get the Angular 2 dev environment ready. Next step is to create an Angular 2 component and an index.html, and execute the command, “npm start”.
When building a Retrieval-Augmented Generation (RAG) application powered by Large Language Models (LLMs), which combine…
Last updated: 25th Jan, 2025 Have you ever wondered how to seamlessly integrate the vast…
Artificial Intelligence (AI) agents have started becoming an integral part of our lives. Imagine asking…
In the ever-evolving landscape of agentic AI workflows and applications, understanding and leveraging design patterns…
In this blog, I aim to provide a comprehensive list of valuable resources for learning…
Have you ever wondered how systems determine whether to grant or deny access, and how…