- download node from https://nodejs.org/en/download/ and it's best to get it again cause you could have an old, stale version
- make a folder somewhere for your app and put five files in it:
- index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Whatever</title>
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script>
System.import('app').catch(function (err) { console.error(err); });
</script>
</head>
<body>
<entry-point>loading...</entry-point>
</body>
</html>
- tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
- package.json:
{
"name": "Whatever",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "~2.1.1",
"@angular/compiler": "~2.1.1",
"@angular/core": "~2.1.1",
"@angular/forms": "~2.1.1",
"@angular/http": "~2.1.1",
"@angular/platform-browser": "~2.1.1",
"@angular/platform-browser-dynamic": "~2.1.1",
"@angular/router": "~3.1.1",
"@angular/upgrade": "~2.1.1",
"angular-in-memory-web-api": "~0.1.13",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "^0.6.25"
},
"devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.45",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3"
}
}
- systemjs.config.js:
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'app',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common':
'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler':
'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-
browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-
browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade':
'npm:@angular/upgrade/bundles/upgrade.umd.js',
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-
web-api/bundles/in-memory-web-api.umd.js'
},
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
- favicon.ico
- index.html:
- run the command prompt as administrator, navigate to your folder, and then run the command: "npm install"
- this will make a "node_modules" folder in your folder and you need to make an "app" folder that sits side by side with it and contains a "main.ts" file with the following inside:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { WrapperOfEverything } from './modules/wrapper-of-everything.module';
const platform = platformBrowserDynamic();
platform.bootstrapModule(WrapperOfEverything);
- you next need to make a "modules" folder within the "app" folder that has "wrapper-of-everything.module.ts" inside of it containing as copy:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { StartingPoint } from '../components/starting-point.component';
import { HttpModule } from '@angular/http';
import { Headers, Http } from '@angular/http';
@NgModule({
imports: [BrowserModule, HttpModule],
declarations: [StartingPoint],
bootstrap: [StartingPoint]
})
export class WrapperOfEverything { }
- now there needs to be a "components" folder in the "app" folder and it needs to hold "starting-point.component.ts" which will have the following copy:
import { Component, Input } from '@angular/core';
import {Http, Headers} from '@angular/http';
import {Observable} from 'rxjs/observable';
@Component({
selector: 'entry-point',
template: 'If you can see this the app works!',
providers: []
})
export class StartingPoint {}
- run the command prompt as administrator, navigate to your folder, and then run the command: "npm start"
- this should compile TypeScript (and recompile TypeScript when it senses you change a file) while also spawning a browser to show you the application you've made
- click Ctrl-C when you are ready to kill the process
the convention of naming a module or a component in kebab case with a trailing .component or .module comes from John Papa and regular objects just have names in kebab case and NOT .object on the end or nuthin'
Addendum 2/10/2017: whatever.service.ts and whatever.model.ts may be perfectly legitimate names per the angular.io style guide.
No comments:
Post a Comment