<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>ng-bootstrap-to-bootstrap-3 demo</title>
<!-- link Bootstrap 3 instead of Bootstrap 4 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<!-- link CSS compatibility patch -->
<link rel="stylesheet" href="https://unpkg.com/ng-bootstrap-to-bootstrap-3@0.7.0" />
<script src="https://unpkg.com/zone.js@^0.7.2/dist/zone.js"></script>
<script src="https://unpkg.com/zone.js@^0.7.2/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@^0.1.8/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@^0.19.40/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app').catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>loading...</my-app>
</body>
</html>
var ver = {
ng: '2.3.1',
ngRouter: '3.3.1'
};
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
paths: {
'npm:': 'https://unpkg.com/'
},
map: {
'app': './src',
'@angular/core': 'npm:@angular/core@' + ver.ng + '/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common@' + ver.ng + '/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler@' + ver.ng + '/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser@' + ver.ng + '/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@' + ver.ng + '/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http@' + ver.ng + '/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router@' + ver.ngRouter + '/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms@' + ver.ng + '/bundles/forms.umd.js',
'rxjs': 'npm:rxjs@5.0.0-rc.4',
'typescript': 'npm:typescript@2.0.10/lib/typescript.js',
'@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap@1.0.0-alpha.21/bundles/ng-bootstrap.js'
},
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule);
import { Component, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { JsonpModule } from '@angular/http';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbdAccordionBasic } from './accordion-basic';
@Component({
selector: 'my-app',
template: `
<h4>Sample Accordion</h4>
<div class="container-fluid">
<ngbd-accordion-basic></ngbd-accordion-basic>
</div>
`
})
export class App {
}
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, JsonpModule, NgbModule.forRoot()],
declarations: [App, NgbdAccordionBasic]
bootstrap: [App]
})
export class AppModule {}
import { Component, ViewChild } from '@angular/core';
import { NgbPanelChangeEvent, NgbAccordion } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-accordion-basic',
templateUrl: 'src/accordion-basic.html'
})
export class NgbdAccordionBasic {
@ViewChild('acc') accordion: NgbAccordion;
model = {};
currentStep = 1;
toggle(step) {
this.currentStep = this.currentStep < step ? step : this.currentStep;
setTimeout(() => this.accordion.toggle('toggle-' + step), 0);
}
beforeChange($event: NgbPanelChangeEvent) {
const availStep = 'toggle-' + this.currentStep;
if ($event.panelId > availStep) {
$event.preventDefault();
}
};
}
<ngb-accordion [closeOthers]="true"
activeIds="toggle-1"
#acc="ngbAccordion"
(panelChange)="beforeChange($event)">
<ngb-panel id="toggle-1">
<template ngbPanelTitle>
<span>Title for Location</span>
</template>
<template ngbPanelContent>
<input type="text"
class="form-control"
name="location"
[(ngModel)]="model.location"
#location
placeholder="Some info" required>
<button type="submit"
value="location-submitted"
class="btn btn-primary blue-btn"
(click)="toggle(2)"><!--showLoadNext = !showLoadNext-->
Next
</button>
</template>
</ngb-panel>
<ngb-panel id="toggle-2" *ngIf="currentStep > 1">
<template ngbPanelTitle>
<span>Title for Load</span>
</template>
<template ngbPanelContent>
<div class="col-xs-12">
<select class="form-control" id="select">
<option>Selection 1</option>
<option>Selection 2</option>
<option>Selection 3</option>
</select>
</div>
<button type="submit"
value="load submitted"
class="btn btn-primary blue-btn"
(click)="toggle(3)"><!--showTariffNext = !showTariffNext-->
Next
</button>
</template>
</ngb-panel>
<ngb-panel id="toggle-3" *ngIf="currentStep > 2">
<template ngbPanelTitle>
<span>Other</span>
</template>
<template ngbPanelContent>
Other.
<div>
<button type="submit"
class="btn btn-primary">
Submit
</button>
</div>
</template>
</ngb-panel>
</ngb-accordion>