/** 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': 'https://unpkg.com/@angular/core/bundles/core.umd.js',
'@angular/animations': 'https://unpkg.com/@angular/animations/bundles/animations.umd.js',
'@angular/common': 'https://unpkg.com/@angular/common/bundles/common.umd.js',
'@angular/common/http': 'https://unpkg.com/@angular/common/bundles/common-http.umd.js',
'@angular/compiler': 'https://unpkg.com/@angular/compiler/bundles/compiler.umd.js',
'@angular/http': 'https://unpkg.com/@angular/http/bundles/http.umd.js',
'@angular/forms': 'https://unpkg.com/@angular/forms/bundles/forms.umd.js',
'@angular/router': 'https://unpkg.com/@angular/router/bundles/router.umd.js',
'@angular/platform-browser': 'https://unpkg.com/@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'https://unpkg.com/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/animations/browser': 'https://unpkg.com/@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations': 'https://unpkg.com/@angular/platform-browser/bundles/platform-browser-animations.umd.js',
// Angular Material and Angular CDK primary bundles.
'@angular/material': 'https://unpkg.com/@angular/material/bundles/material.umd.js',
'@angular/cdk': 'https://unpkg.com/@angular/cdk/bundles/cdk.umd.js',
// CDK Secondary entry points
'@angular/cdk/a11y': 'https://unpkg.com/@angular/cdk/bundles/cdk-a11y.umd.js',
'@angular/cdk/accordion': 'https://unpkg.com/@angular/cdk/bundles/cdk-accordion.umd.js',
'@angular/cdk/bidi': 'https://unpkg.com/@angular/cdk/bundles/cdk-bidi.umd.js',
'@angular/cdk/coercion': 'https://unpkg.com/@angular/cdk/bundles/cdk-coercion.umd.js',
'@angular/cdk/collections': 'https://unpkg.com/@angular/cdk/bundles/cdk-collections.umd.js',
'@angular/cdk/keycodes': 'https://unpkg.com/@angular/cdk/bundles/cdk-keycodes.umd.js',
'@angular/cdk/observers': 'https://unpkg.com/@angular/cdk/bundles/cdk-observers.umd.js',
'@angular/cdk/overlay': 'https://unpkg.com/@angular/cdk/bundles/cdk-overlay.umd.js',
'@angular/cdk/platform': 'https://unpkg.com/@angular/cdk/bundles/cdk-platform.umd.js',
'@angular/cdk/portal': 'https://unpkg.com/@angular/cdk/bundles/cdk-portal.umd.js',
'@angular/cdk/scrolling': 'https://unpkg.com/@angular/cdk/bundles/cdk-scrolling.umd.js',
'@angular/cdk/table': 'https://unpkg.com/@angular/cdk/bundles/cdk-table.umd.js',
'@angular/cdk/stepper': 'https://unpkg.com/@angular/cdk/bundles/cdk-stepper.umd.js',
'@angular/cdk/layout': 'https://unpkg.com/@angular/cdk/bundles/cdk-layout.umd.js',
// Rxjs mapping
'rxjs': 'https://unpkg.com/rxjs',
// TODO(josephperrott): Determine why this is needed and get it removed.
'tslib': 'https://unpkg.com/tslib/tslib.js'
},
packages: {
// Thirdparty barrels.
'rxjs': { main: 'index' },
}
});
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatDatepickerModule,
MatDialogModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatStepperModule,
} from '@angular/material';
import {HttpModule} from '@angular/http';
import {CdkTableModule} from '@angular/cdk/table';
import {ToughChoiceComponent} from './tough-choice.component';
import {FoodComponent} from './food/food.component';
import {PieComponent} from './pie/pie.component';
import {FoodService} from './food.service';
@NgModule({
exports: [
CdkTableModule,
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatStepperModule,
MatDatepickerModule,
MatDialogModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
]
})
export class PlunkerMaterialModule {}
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
PlunkerMaterialModule,
MatNativeDateModule,
ReactiveFormsModule,
],
providers: [FoodService]
declarations: [
ToughChoiceComponent,
FoodComponent,
PieComponent
],
bootstrap: [ToughChoiceComponent]
})
export class PlunkerAppModule {}
platformBrowserDynamic().bootstrapModule(PlunkerAppModule);
import { Component } from '@angular/core';
@Component({
selector: 'tough-choice',
templateUrl: 'tough-choice.component.html',
styleUrls: []
})
export class ToughChoiceComponent {
isLinear = true;
constructor() { }
ngOnInit() { }
}
<!DOCTYPE html>
<html>
<head>
<title>Angular Material Plunker</title>
<!-- Load common libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/2.1.1/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.8.5/zone.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<script src="config.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 stylesheet -->
<link href="https://unpkg.com/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>body { font-family: Roboto, Arial, sans-serif; }</style>
</head>
<body>
<tough-choice>Loading example...</tough-choice>
</body>
</html>
<mat-horizontal-stepper [linear]="true">
<mat-step [stepControl]="foodFormGroup">
<food-selection></food-selection>
</mat-step>
<mat-step [stepControl]="pieFormGroup">
<pie-selection></pie-selection>
</mat-step>
</mat-horizontal-stepper>
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FoodService } from '../food.service';
@Component({
selector: 'food-selection',
templateUrl: './food/food.component.html',
styleUrls: []
})
export class FoodComponent implements OnInit {
foodFormGroup: FormGroup;
foods: string[] = [];
constructor(private foodService: FoodService, private _formBuilder: FormBuilder) { }
ngOnInit() {
this.foodFormGroup = this._formBuilder.group({
foodSelector: ['', Validators.required]
});
this.foods.push("Meat", "Fruit");
}
setFood(food: string) {
this.foodService.selectedFood = food;
}
}
<form [formGroup]="foodFormGroup">
<ng-template matStepLabel>Food Selection</ng-template>
<mat-form-field>
<mat-select placeholder="Select a Food" formControlName="foodSelector" (change)="setFood(food)">
<mat-option *ngFor="let food of foods" [value]="food">{{food}}</mat-option>
</mat-select>
</mat-form-field>
<div>
<button mat-button matStepperNext [disabled]="!foodFormGroup.valid">Next</button>
</div>
</form>
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { FoodService } from '../food.service';
@Component({
selector: 'pie-selection',
templateUrl: './pie/pie.component.html',
styleUrls: []
})
export class PieComponent implements OnInit {
pieFormGroup: FormGroup;
selectedPie: string;
constructor(private foodService: FoodService, private _formBuilder: FormBuilder) {
}
ngOnInit() {
this.pieFormGroup = this._formBuilder.group({
pieInput: [this.selectedPie, Validators.required]
});
this.foodService.getFood()
.subscribe(food => this.selectedPie = food + " pie!");
}
}
<form [formGroup]="pieFormGroup">
<ng-template matStepLabel>Pie Choice</ng-template>
<span>You chose a </span>
<mat-form-field>
<input formControlName="pieInput" matInput placeholder="Favorite pie" value="{{selectedPie}}">
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Previous</button>
</div>
</form>
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { of } from 'rxjs/observable/of';
@Injectable()
export class FoodService {
selectedFood: string;
getFood(): Observable<string> {
return of(this.selectedFood);
}
}
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: {
app: "./src"
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
}
}
});