<!DOCTYPE html>
<html>
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
<title>Angular 2 Material Plunker</title>
<!-- Load common libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/2.0.3/typescript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.6.26/zone.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.40/system.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<!-- Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System
.import('main.ts')
.catch(console.error.bind(console));
</script>
<!-- Load the Angular Material 2 stylesheet -->
<link href="https://unpkg.com/@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
</head>
<body>
<material-app>Loading the Angular 2 Material App...</material-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
-->
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
@Component({
selector: 'material-app',
template: `
<router-outlet></router-outlet>
`
})
export class AppComponent {}
/*
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
*/
/** Add Transpiler for Typescript */
System.config({
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
},
packages: {
'.': {
defaultExtension: 'ts'
},
'vendor': {
defaultExtension: 'js'
}
}
});
System.config({
map: {
'main': 'main.js',
// Angular specific mappings.
'@angular/core': 'http://unpkg.com/@angular/core/bundles/core.umd.js',
'@angular/common': 'http://unpkg.com/@angular/common/bundles/common.umd.js',
'@angular/compiler': 'http://unpkg.com/@angular/compiler/bundles/compiler.umd.js',
'@angular/http': 'http://unpkg.com/@angular/http/bundles/http.umd.js',
'@angular/forms': 'http://unpkg.com/@angular/forms/bundles/forms.umd.js',
'@angular/router': 'http://unpkg.com/@angular/router/bundles/router.umd.js',
'@angular/platform-browser': 'http://unpkg.com/@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'http://unpkg.com/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/material': 'https://rawgit.com/DevVersion/8a07cf937d8957907d7b8cdc95c4db63/raw/ab70650efeabfa08ed9268a55c4ef85511019e46/material.umd.js',
// Rxjs mapping
'rxjs': 'https://unpkg.com/rxjs',
},
packages: {
// Thirdparty barrels.
'rxjs': { main: 'index' },
}
});
/*
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 {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {MaterialModule} from '@angular/material';
import {routing} from './routing';
@NgModule({
imports: [
BrowserModule,
MaterialModule.forRoot(),
routing
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: []
})
export class PlunkerAppModule {}
platformBrowserDynamic().bootstrapModule(PlunkerAppModule);
/*
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 { Routes, RouterModule } from "@angular/router";
const routes: Routes = [
{
path:'',
loadChildren:'./lazy.module#LazyModule'
}
];
export const routing = RouterModule.forRoot(routes);
import {NgModule} from '@angular/core';
import {MaterialModule} from '@angular/material';
import {LazyComponent} from './lazy.component';
import {LazyDialogComponent} from './lazy-dialog.component';
import {LazyService} from './lazy.service';
import {lazyRouting} from './lazy.routing';
@NgModule({
imports: [
MaterialModule,
lazyRouting
],
declarations: [
LazyComponent,
LazyDialogComponent
],
entryComponents: [
LazyDialogComponent
],
providers: [
LazyService
]
})
export class LazyModule {}
import { Component, ViewContainerRef } from '@angular/core';
import { MdDialog, MdDialogConfig } from '@angular/material';
import { LazyDialogComponent } from './lazy-dialog.component.ts'
@Component({
selector: 'lazy',
template: `
<md-card>
<button on-click="onGenerateError()" md-raised-button>Generate Error!</button>
</md-card>
`,
styles:[]
})
export class LazyComponent {
constructor(private viewContainerRef: ViewContainerRef,
private dialogService: MdDialog) {}
onGenerateError():void {
let config = new MdDialogConfig();
config.viewContainerRef = this.viewContainerRef;
this.dialogService.open(LazyDialogComponent, config);
}
}
import { Component, OnInit, ViewContainerRef } from '@angular/core';
import { MdDialogRef } from '@angular/material';
import { LazyService } from './lazy.service';
@Component({
selector:'lazy-dialog',
template:`
<h1>Lazy dialog does not work</h1>
`,
styles:[])
export class LazyDialogComponent {
constructor(private dialogRef: MdDialogRef<LazyDialogComponent>,
private lazyService: LazyService) {}
}
import { Injectable } from '@angular/core';
@Injectable()
export class LazyService {}
import { Routes, RouterModule } from "@angular/router";
import {LazyComponent} from './lazy.component';
const lazyRoutes:Routes = [
{
path: '**',
component: LazyComponent
}
];
export const lazyRouting = RouterModule.forChild(lazyRoutes);