<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>angular2 playground</title>
<link rel="stylesheet" href="style.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js/dist/zone.js"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ"
crossorigin="anonymous">
</head>
<body>
<div class='container-fluid'>
<my-app>
loading...
</my-app>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n"
crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.1/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn"
crossorigin="anonymous"></script>
</body>
</html>
/* Styles go here */
### Angular Starter Plunker - Typescript
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
paths: {
'npm:': 'https://unpkg.com/'
},
//map tells the System loader where to look for things
map: {
'app': './src',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
'ng-bootstrap-form-generator': 'npm:ng-bootstrap-form-generator@0.1.0/src/index.js'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import { BootstrapFormGeneratorModule, BsfControlOptions } from 'ng-bootstrap-form-generator';
@Component({
selector: 'my-app',
template: `
<bsf-form [options]='formConfig' [(value)]='data' #regForm>
<bsf-before>
<h5>New User</h5>
</bsf-before>
<bsf-after>
<button type="button" class="btn btn-primary" (click)='sendForm(regForm.value, regForm.form.valid)'>Register</button>
<button type="button" class="btn btn-default" (click)='reset()'>Clear</button>
<span>{{message}}</span>
</bsf-after>
</bsf-form>
<br>
<pre>{{data|json}}</pre>
`,
})
export class App {
message: string;
formConfig: BsfControlOptions[];
data = {
id: '123',
email: 'boby.mobi@example.com',
name: 'Mobibob',
password: 'AOe30&^@#!c2',
howUserFindUs: '2',
agreement: true,
};
constructor() { }
reset() {
this.data = {
id: null,
email: null,
name: null,
password: null,
howUserFindUs: null,
agreement: null,
};
}
sendForm(data, valid: boolean) {
if (valid) {
this.message = 'Registration form sent';
} else {
this.message = 'Please fill form and fix all errors';
}
}
ngOnInit() {
this.formConfig = this.formConfig = [
{
field: 'id',
type: 'hidden',
},
{
field: 'email',
type: 'email',
title: 'Email',
helpText: 'We will send confirmation email in order to finish registration',
required: true
},
{
field: 'name',
type: 'text',
title: 'User Name',
required: true,
maxlength: 15
},
{
field: 'password',
type: 'password',
title: 'Password',
helpText: 'Password should be strong',
required: true,
minlength: 6
},
{
field: 'howUserFindUs',
type: 'select',
title: 'How did you find us?',
helpText: 'You can keep this field empty',
select: {
emptyText: '-- How did you hear of us? --',
options: [
{ text: 'Facebook', value: 1 },
{ text: 'LinkedIn', value: 2 },
{ text: 'Google', value: 3 },
{ text: 'Friends', value: 4 },
]
}
},
{
field: 'agreement',
type: 'checkbox',
title: 'I accept license agreement',
helpTextHtml: 'Read <a href="#license ">license</a> before accept',
requiredTrue: true,
validationMessage: {
required: 'Please, read and accept agreement'
},
}
];
}
}
@NgModule({
imports: [ BrowserModule, BootstrapFormGeneratorModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}