<!DOCTYPE html>
<html>
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
<title>NgModule Deluxe</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- Polyfill(s) for older browsers -->
<script src="https://npmcdn.com/core-js/client/shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
<!--
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
/**
* PLUNKER VERSION (based on systemjs.config.js in angular.io)
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {
var ngVer = '@2.0.0-rc.5'; // lock in the angular package version; do not let it float to current!
var routerVer = '@3.0.0-rc.1'; // lock router version
var formsVer = '@0.3.0'; // lock forms version
var routerDeprecatedVer = '@2.0.0-rc.2'; // temporarily until we update all the guides
var angular2ModalVer = '@2.0.0-beta.11';
var plugin = 'bootstrap'; // js-native / vex
global.angular2ModalVer = angular2ModalVer;
//map tells the System loader where to look for things
var map = {
'app': 'app',
'@angular': 'https://unpkg.com/@angular', // sufficient if we didn't pin the version
'@angular/router': 'https://unpkg.com/@angular/router' + routerVer,
'@angular/forms': 'https://unpkg.com/@angular/forms' + formsVer,
'@angular/router-deprecated': 'https://unpkg.com/@angular/router-deprecated' + routerDeprecatedVer,
'angular2-in-memory-web-api': 'https://unpkg.com/angular2-in-memory-web-api', // get latest
'rxjs': 'https://unpkg.com/rxjs@5.0.0-beta.6',
'ts': 'https://unpkg.com/plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'https://unpkg.com/typescript@1.9.0-dev.20160409/lib/typescript.js',
'angular2-modal': 'https://unpkg.com/angular2-modal' + angular2ModalVer
};
//packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.ts', defaultExtension: 'ts' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'angular2-modal': { defaultExtension: 'js', main: 'bundles/angular2-modal.umd' }
};
// UMD bundles
map[`angular2-modal/plugins/${plugin}`] = map['angular2-modal'] + '/bundles';
packages[`angular2-modal/plugins/${plugin}`] = { defaultExtension: 'js', main: `angular2-modal.${plugin}.umd` };
// Uncomment to use Individual files/modules
// map[`angular2-modal/plugins/${plugin}`] = map['angular2-modal'] + `/plugins/${plugin}`;
// packages['angular2-modal'] = { defaultExtension: 'js', main: 'index' };
// packages[`angular2-modal/plugins/${plugin}`] = { defaultExtension: 'js', main: `index` };
var ngPackageNames = [
'common',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'upgrade',
];
// Add map entries for each angular package
// only because we're pinning the version with `ngVer`.
ngPackageNames.forEach(function(pkgName) {
map['@angular/'+pkgName] = 'https://npmcdn.com/@angular/' + pkgName + ngVer;
});
// Add package entries for angular packages
ngPackageNames.concat(['forms', 'router', 'router-deprecated']).forEach(function(pkgName) {
// Bundled (~40 requests):
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
// Individual files (~300 requests):
//packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
tsconfig: true
},
meta: {
'typescript': {
"exports": "ts"
}
},
map: map,
packages: packages
};
System.config(config);
})(this);
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
// The browser platform with a compiler
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
// The app module
import { AppModule } from './app.module';
// Compile and launch the module
platformBrowserDynamic().bootstrapModule(AppModule);
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ModalModule } from 'angular2-modal';
import { BootstrapModalModule } from 'angular2-modal/plugins/bootstrap';
import { AppComponent } from './app.component';
import { CustomModal } from './custom-modal-sample';
@NgModule({
imports: [
BrowserModule,
ModalModule.forRoot(),
BootstrapModalModule
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
// IMPORTANT:
// Since 'AdditionCalculateWindow' is never explicitly used (in a template)
// we must tell angular about it.
entryComponents: [ CustomModal ]
})
export class AppModule { }
import { Component, ViewContainerRef, ViewEncapsulation } from '@angular/core';
import { Overlay, overlayConfigFactory } from 'angular2-modal';
import { Modal, BSModalContext } from 'angular2-modal/plugins/bootstrap';
import { CustomModalContext, CustomModal } from './custom-modal-sample';
@Component({
selector: 'my-app',
template: `
<span defaultOverlayTarget></span>
<h1>angular2-modal{{version}}</h1>
<h2>Basic Modal sample</h2>
<button (click)="onClick()">Alert</button>
<br>
<h2>Custom Modal example:</h2>
<button (click)="openCustom()">Custom Modal</button>
<p>
<b>IMPORTANT:</b>
Since 'AdditionCalculateWindow' is never explicitly used (in a template)
we must tell angular about it by adding it to the <strong>entryComponents</strong> property in the module meta.
</p>
<h2>See systemjs.config.js implementation for UMD vs module loading</h2>
`,
providers: [Modal]
})
export class AppComponent {
constructor(public modal: Modal) {
}
get version(): string {
return window.angular2ModalVer;
}
onClick() {
this.modal.alert()
.size('lg')
.showClose(true)
.title('A simple Alert style modal window')
.body(`
<h4>Alert is a classic (title/body/footer) 1 button modal window that
does not block.</h4>
<b>Configuration:</b>
<ul>
<li>Non blocking (click anywhere outside to dismiss)</li>
<li>Size large</li>
<li>Dismissed with default keyboard key (ESC)</li>
<li>Close wth button click</li>
<li>HTML content</li>
</ul>`)
.open();
}
openCustom() {
return this.modal.open(CustomModal, overlayConfigFactory({ num1: 2, num2: 3 }, BSModalContext));
}
}
import { Component } from '@angular/core';
import { DialogRef, ModalComponent, CloseGuard } from 'angular2-modal';
import { BSModalContext } from 'angular2-modal/plugins/bootstrap';
export class CustomModalContext extends BSModalContext {
public num1: number;
public num2: number;
}
/**
* A Sample of how simple it is to create a new window, with its own injects.
*/
@Component({
selector: 'modal-content',
styles: [`
.custom-modal-container {
padding: 15px;
}
.custom-modal-header {
background-color: #219161;
color: #fff;
-webkit-box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.75);
margin-top: -15px;
margin-bottom: 40px;
}
`],
//TODO: [ngClass] here on purpose, no real use, just to show how to workaround ng2 issue #4330.
// Remove when solved.
/* tslint:disable */ template: `
<div class="container-fluid custom-modal-container">
<div class="row custom-modal-header">
<div class="col-sm-12">
<h1>A Custom modal design</h1>
</div>
</div>
<div class="row" [ngClass]="{'myclass' : shouldUseMyClass}">
<div class="col-xs-12">
<div class="jumbotron">
<h1>Do the math to quit:</h1>
<p class="lead">I received an injection of the number <strong>{{context.num1}}</strong> and the number <strong>{{context.num2}}</strong></p>
<span>What is the sum?</span>
<input class="form-control" type="text" #answer (keyup)="onKeyUp(answer.value)" autofocus>
</div>
</div>
</div>
</div>`
})
export class CustomModal implements CloseGuard, ModalComponent<CustomModalContext> {
context: CustomModalContext;
public wrongAnswer: boolean;
constructor(public dialog: DialogRef<CustomModalContext>) {
this.context = dialog.context;
this.wrongAnswer = true;
dialog.setCloseGuard(this);
}
onKeyUp(value) {
this.wrongAnswer = value != 5;
this.dialog.close();
}
beforeDismiss(): boolean {
return true;
}
beforeClose(): boolean {
return this.wrongAnswer;
}
}