<!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<link href="style.css" rel="stylesheet" />
<script src="https://code.angularjs.org/2.0.0-beta.0/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.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2.min.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/http.min.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, View} from 'angular2/core'
import {MaterialDesignDirective} from './MaterialDesign';
@Component({
selector: 'my-app'
})
@View({
template: `
<div class="md-input-wrapper">
<input type="text" class="md-input">
</div>
`,
directives: [MaterialDesignDirective]
})
export class App {
constructor() {}}
}
import {Directive, ElementRef, Renderer} from 'angular2/core';
@Directive({
selector: '.md-input',
// Commented out so page will run - uncomment to see error
/*
host: {
'(focus)': 'setInputFocus(true)',
'(blur)': 'setInputFocus(false)',
}
*/
})
export class MaterialDesignDirective {
renderer: Renderer;
el: ElementRef;
constructor(el: ElementRef, renderer: Renderer) {
this.renderer = renderer;
this.el = el;
}
setInputFocus() {
this.renderer.setElementClass(this.el.nativeElement.parentElement, 'md-input-focus', true);
}
}