-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from raymonschouwenaar/step-5-create-simple-form
Step 5 create simple form
- Loading branch information
Showing
13 changed files
with
8,901 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build] | ||
command = "npm run build:prod" | ||
publish = "dist/angular-ngx-formly-material" | ||
|
||
[context.deploy-preview] | ||
command = "npm run build-preview" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"useTabs": true, | ||
"tabWidth": 4, | ||
"semi": false, | ||
"bracketSpacing": true, | ||
"trailingComma": "all", | ||
"arrowParens": "always", | ||
"endOfLine": "auto", | ||
"overrides": [ | ||
{ | ||
"files": ["*.yaml", "*.yml"], | ||
"options": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false | ||
} | ||
} | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* /index.html 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.container { | ||
max-width: 700px; | ||
margin: 0 auto | ||
} | ||
|
||
formly-form { | ||
display: block; | ||
margin-bottom: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,120 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component } from '@angular/core' | ||
import { FormGroup } from '@angular/forms' | ||
import { FormlyFieldConfig } from '@ngx-formly/core' | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
selector: 'app-root', | ||
// templateUrl: './app.component.html', | ||
template: ` | ||
<div class="container"> | ||
<h1>{{ title }}</h1> | ||
<p>This is an example form based on the Medium tutorial.</p> | ||
<form [formGroup]="form" (ngSubmit)="onSubmit()"> | ||
<formly-form [form]="form" [fields]="fields" [model]="model"></formly-form> | ||
<button type="submit" mat-raised-button color="primary" class="button--submit">Submit</button> | ||
</form> | ||
<pre> | ||
{{model | json}} | ||
</pre> | ||
</div> | ||
`, | ||
styleUrls: ['./app.component.scss'], | ||
}) | ||
export class AppComponent { | ||
title = 'angular-ngx-formly-material'; | ||
title = 'Angular NGX-Formly with Material' | ||
form = new FormGroup({}) | ||
model = { | ||
email: "email@gmail.com", | ||
terms_1: false, | ||
terms: true, | ||
date_of_birth: new Date(), | ||
amount: 100, | ||
name: "lskdfnlksdf", | ||
description: "laksndlkansd↵asd↵nlkxclkzxc↵", | ||
gender: 3 | ||
} | ||
fields: FormlyFieldConfig[] = [ | ||
{ | ||
key: 'name', | ||
type: 'input', | ||
templateOptions: { | ||
label: 'Name', | ||
placeholder: 'Enter name', | ||
} | ||
}, | ||
{ | ||
key: 'email', | ||
type: 'input', | ||
templateOptions: { | ||
type: 'email', | ||
label: 'Email', | ||
placeholder: 'Enter email', | ||
} | ||
}, | ||
{ | ||
key: 'amount', | ||
type: 'input', | ||
templateOptions: { | ||
type: 'number', | ||
label: 'Amount', | ||
placeholder: 'Enter amount', | ||
} | ||
}, | ||
{ | ||
key: 'date_of_birth', | ||
type: 'datepicker', | ||
templateOptions: { | ||
label: 'Datepicker', | ||
placeholder: 'Placeholder', | ||
description: 'Description', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
key: 'terms', | ||
type: 'checkbox', | ||
templateOptions: { | ||
label: 'Accept terms', | ||
description: 'Please accept our terms', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
key: 'terms_1', | ||
type: 'toggle', | ||
templateOptions: { | ||
label: 'Accept terms', | ||
description: 'Please accept our terms', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
key: 'description', | ||
type: 'textarea', | ||
templateOptions: { | ||
label: 'Description', | ||
placeholder: 'Enter description', | ||
} | ||
}, | ||
{ | ||
key: 'gender', | ||
type: 'radio', | ||
templateOptions: { | ||
label: 'Gender', | ||
placeholder: 'Placeholder', | ||
description: 'Fill in your gender', | ||
options: [ | ||
{ value: 1, label: 'Male' }, | ||
{ value: 2, label: 'Female' }, | ||
{ value: 3, label: 'I don\'t want to share that' }, | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
onSubmit() { | ||
console.log(this.model) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,50 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' | ||
import { BrowserModule } from '@angular/platform-browser' | ||
import { NgModule } from '@angular/core' | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { AppComponent } from './app.component'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { FormlyModule } from '@ngx-formly/core'; | ||
import { FormlyMaterialModule } from '@ngx-formly/material'; | ||
import { AppRoutingModule } from './app-routing.module' | ||
import { AppComponent } from './app.component' | ||
import { ReactiveFormsModule } from '@angular/forms' | ||
import { FormlyModule } from '@ngx-formly/core' | ||
import { FormlyMaterialModule } from '@ngx-formly/material' | ||
import { FormlyMatDatepickerModule } from '@ngx-formly/material/datepicker'; | ||
import { FormlyMatToggleModule } from '@ngx-formly/material/toggle'; | ||
|
||
import { MatDatepickerModule } from '@angular/material/datepicker' | ||
import { MatDialogModule } from '@angular/material/dialog' | ||
import { MatFormFieldModule } from '@angular/material/form-field' | ||
import { MatInputModule } from '@angular/material/input' | ||
import { MatRadioModule } from '@angular/material/radio' | ||
import { MatSelectModule } from '@angular/material/select' | ||
import { MatButtonModule } from '@angular/material/button' | ||
import { MatCheckboxModule } from '@angular/material/checkbox' | ||
import { MatNativeDateModule } from '@angular/material/core' | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
AppRoutingModule, | ||
ReactiveFormsModule, | ||
FormlyModule.forRoot(), | ||
FormlyMaterialModule | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent] | ||
declarations: [AppComponent], | ||
imports: [ | ||
BrowserModule, | ||
AppRoutingModule, | ||
BrowserAnimationsModule, | ||
|
||
ReactiveFormsModule, | ||
MatCheckboxModule, | ||
MatButtonModule, | ||
MatDatepickerModule, | ||
MatDialogModule, | ||
MatFormFieldModule, | ||
MatInputModule, | ||
MatRadioModule, | ||
MatSelectModule, | ||
|
||
MatNativeDateModule, | ||
FormlyMatDatepickerModule, | ||
FormlyMatToggleModule, | ||
|
||
FormlyModule.forRoot(), | ||
FormlyMaterialModule, | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule { } | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AngularNgxFormlyMaterial</title> | ||
<base href="/"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>AngularNgxFormlyMaterial</title> | ||
<base href="/" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet" /> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/* You can add global styles to this file, and also import other style files */ | ||
@import '@angular/material/prebuilt-themes/deeppurple-amber.css'; | ||
|
||
body { | ||
font-family: "Roboto", Arial, Helvetica, sans-serif; | ||
line-height: 1.3; | ||
font-size: 1.2rem; | ||
} |
Oops, something went wrong.