<!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<link rel="stylesheet" href="style.css" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/flot/0.8.1/jquery.flot.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/flot/0.8.1/jquery.flot.categories.min.js"></script>
<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('vasia')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app> </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: {
vasia: "./src"
},
//packages defines our app package
packages: {
vasia: {
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} from 'angular2/core'
import {FlotCmp} from './flot';
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<flot [options]="splineOptions" [dataset]="dataset" height="250px" width="100%"></flot>
</div>
`,
directives: [FlotCmp]
})
export class App {
constructor() {
this.name = 'Angular2'
this.splineOptions: any = {
series: {
lines: { show: true },
points: {
radius: 3,
show: true
}
}
};
this.dataset = [{label: "line1",color:"blue",data: [[1, 130], [2, 40], [3, 80], [4, 160], [5, 159], [6, 370], [7, 330], [8, 350], [9, 370], [10, 400], [11, 330], [12, 350]]}];
}
}
import {Component, ElementRef, Input, AfterViewInit} from 'angular2/core';
@Component({
selector: 'flot',
template: `<div>loading</div>`
})
export class FlotCmp implements AfterViewInit{
private width = '100%';
private height = 220;
static chosenInitialized = false;
@Input() private options: any;
@Input() private dataset:any;
@Input() private width:string;
@Input() private height:string;
constructor(public el: ElementRef) {}
ngAfterViewInit() {
if(!FlotCmp.chosenInitialized) {
let plotArea = $(this.el.nativeElement).find('div').empty();
plotArea.css({
width: this.width,
height: this.height
});
$.plot( plotArea, this.dataset, this.options);
FlotCmp.chosenInitialized = true;
}
}
}