<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>ng-bootstrap demo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<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.20/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 { NgbdDatepickerI18n } from './datepicker-i18n';
@Component({
selector: 'my-app',
template: `
<div class="container-fluid">
<hr>
<p>
This is a demo plnkr forked from the <strong>ng-bootstrap</strong> project: Angular powered Bootstrap.
Visit <a href="https://ng-bootstrap.github.io/" target="_blank">https://ng-bootstrap.github.io</a> for more widgets and demos.
</p>
<hr>
<ngbd-datepicker-i18n></ngbd-datepicker-i18n>
</div>
`
})
export class App {
}
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, JsonpModule, NgbModule.forRoot()],
declarations: [App, NgbdDatepickerI18n]
bootstrap: [App]
})
export class AppModule {}
import {Component, Injectable} from '@angular/core';
import {NgbDatepickerI18n} from '@ng-bootstrap/ng-bootstrap';
const I18N_VALUES = {
en: {
weekdays: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
},
fr: {
weekdays: ['Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di'],
months: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Aou', 'Sep', 'Oct', 'Nov', 'Déc'],
}
};
// Define a service holding the language. You probably already have one if your app is i18ned.
@Injectable()
export class I18n {
language = 'en';
}
// Define custom service providing the months and weekdays translations
@Injectable()
export class CustomDatepickerI18n extends NgbDatepickerI18n {
constructor(private _i18n: I18n) {
super();
}
getWeekdayShortName(weekday: number): string {
return I18N_VALUES[this._i18n.language].weekdays[weekday - 1];
}
getMonthShortName(month: number): string {
return I18N_VALUES[this._i18n.language].months[month - 1];
}
getMonthFullName(month: number): string {
return this.getMonthShortName(month);
}
}
@Component({
selector: 'ngbd-datepicker-i18n',
templateUrl: 'src/datepicker-i18n.html',
providers: [I18n, {provide: NgbDatepickerI18n, useClass: CustomDatepickerI18n}] // define custom NgbDatepickerI18n provider
})
export class NgbdDatepickerI18n {
model;
constructor(private _i18n: I18n) {}
set language(language: string) {
this._i18n.language = language;
}
get language() {
return this._i18n.language;
}
}
<div [(ngModel)]="language" ngbRadioGroup>
<label class="btn btn-primary">
<input type="radio" value="en"> English
</label>
<label class="btn btn-primary">
<input type="radio" value="fr"> Français
</label>
</div>
<hr>
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input class="form-control" placeholder="yyyy-mm-dd"
name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">
<div class="input-group-addon" (click)="d.toggle()" >
<img src="img/calendar-icon.svg" style="width: 1.2rem; height: 1rem; cursor: pointer;"/>
</div>
</div>
</div>
</form>