This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ ** Install and initialize jspm**
2
+ ```
3
+ npm install -g jspm@beta
4
+ jspm init
5
+
6
+ ```
7
+ Pick default answer for all questions except ` Which ES6 transpiler would you like to use? ` , as an answer type ` typescript ` .
8
+
9
+ ** run:**
10
+ - install http-server package via
11
+ ```
12
+ npm install -g http-server
13
+ ```
14
+ - run server (if port 8080 it taken, pick any port that is free)
15
+ ```
16
+ http-server -p 8080
17
+ ```
Original file line number Diff line number Diff line change
1
+ import { Greeter } from 'greeter'
2
+
3
+ export function main ( el : HTMLElement ) : void {
4
+ let greeter = new Greeter ( el ) ;
5
+ greeter . start ( ) ;
6
+ }
Original file line number Diff line number Diff line change
1
+ export class Greeter
2
+ {
3
+ element : HTMLElement ;
4
+ span : HTMLElement ;
5
+ timerToken : number ;
6
+
7
+ constructor ( element : HTMLElement )
8
+ {
9
+ this . element = element ;
10
+ this . element . innerText += "The time is: " ;
11
+ this . span = document . createElement ( 'span' ) ;
12
+ this . element . appendChild ( this . span ) ;
13
+ this . span . innerText = new Date ( ) . toUTCString ( ) ;
14
+ }
15
+
16
+ start ( )
17
+ {
18
+ this . timerToken = setInterval ( ( ) => this . span . innerText = new Date ( ) . toUTCString ( ) , 500 ) ;
19
+ }
20
+
21
+ stop ( )
22
+ {
23
+ clearTimeout ( this . timerToken ) ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < title > Jspm sample</ title >
4
+ < script src ="jspm_packages/system.src.js "> </ script >
5
+ < script src ="config.js "> </ script >
6
+ </ head >
7
+ < body >
8
+ < div id ="content "> </ div >
9
+ < script >
10
+ System . config ( {
11
+ "paths" : {
12
+ "app.js" :"app.ts" ,
13
+ "greeter.js" :"greeter.ts"
14
+ }
15
+ } ) ;
16
+ System . import ( 'app' ) . then ( function ( m ) {
17
+ var element = document . getElementById ( "content" ) ;
18
+ m . main ( element ) ;
19
+ } ) ;
20
+ </ script >
21
+ </ body >
22
+ </ html >
You can’t perform that action at this time.
0 commit comments