<!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<link rel="stylesheet" href="style.css" />
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="../config.html"></script>
<script src="https://code.angularjs.org/2.0.0-beta.16/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.16/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.16/http.dev.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
/* Styles go here */
### Angular2 Starter Plunker - Typescript - Beta 0
A simple plunker demonstrating Angular2 usage:
- Uses SystemJS + TypeScript to compile on the fly
- Includes binding, directives, http, pipes, and DI usage.
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
app: "./src"
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
}
}
});
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';
bootstrap(App, [])
.catch(err => console.error(err));
//our root app component
import {Component, OnInit, ChangeDetectionStrategy} from 'angular2/core'
@Component({
selector: 'my-app',
providers: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div>
<h2>Hello {{_model.firstName}}</h2>
<form>
<div class="form-group">
<input *ngIf="_model" type="text" class="form-control" required [(ngModel)]="_model.firstName" ngControl="firstName">
</div>
<template [ngIf]="_model">
<input type="text" class="form-control" required [(ngModel)]="_model.firstName" ngControl="test2" #myInput >
<br>Class: {{myInput?.className}}
</template>
<br>Class: {{myInput?.className}}
<br>Class: {{myInput2?.className}}
<br>Class: {{_model?.firstName}}
</form>
</div>
`,
directives: []
})
export class App implements OnInit {
private _model: Object;
constructor() {
this.name = 'Angular2'
}
ngOnInit() {
this._model = {
firstName: "This is a test"
}
}
}