<!DOCTYPE html>
<html>
<head>
<title>Angular 2 UI Components - Modern JS</title>
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app').then(null, console.error.bind(console));
</script>
</head>
<body>
<banner-app>Loading...</banner-app>
</body>
</html>
import {platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import {BannerModule} from './banner.module';
platformBrowserDynamic().bootstrapModule(BannerModule);
import {Component} from '@angular/core';
@Component({
selector: 'banner-app',
template: `
<div>
<h4><button (click)="handleClick()">Click to {{isTheBannerVisible ? 'hide' : 'show'}} {{message}}</button></h4>
<div [hidden]="!isTheBannerVisible">{{message}}</div>
</div>
`
})
export class Banner {
message: string = "Angular 101!";
isTheBannerVisible: boolean = true;
handleClick(event) {
this.isTheBannerVisible = !this.isTheBannerVisible;
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Banner } from './banner.component';
@NgModule( {
imports: [ BrowserModule ],
declarations: [ Banner ],
exports: [ Banner ],
bootstrap: [ Banner ]
} )
export class BannerModule {
}
System.config({
transpiler: 'ts',
typescriptOptions: {
// Copy of compiler options in standard tsconfig.json
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
// paths serve as alias
'npm:': 'https://unpkg.com/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@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',
// other libraries
'rxjs': 'npm:rxjs',
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'npm:typescript@2.0.3/lib/typescript.js',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});