From c13dfc54fd77515e4e8ec124f341b5b803cc3bba Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 9 May 2017 17:43:48 +0100 Subject: [PATCH] Fixed form and interacts with server more --- src/app/app.module.ts | 3 --- src/app/pages/pages.module.ts | 9 ++++++- src/app/pages/register.component.html | 13 +++++---- src/app/pages/register.component.ts | 39 ++++++++++++++------------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2487471..c1cca0c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -2,7 +2,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { HttpModule } from '@angular/http'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; @@ -26,8 +25,6 @@ import { SimpleLayoutComponent } from './layouts/simple-layout.component'; BrowserModule, AppRoutingModule, HttpModule, - FormsModule, - ReactiveFormsModule, BsDropdownModule.forRoot(), TabsModule.forRoot(), ChartsModule diff --git a/src/app/pages/pages.module.ts b/src/app/pages/pages.module.ts index 9c79c6a..933aa1c 100644 --- a/src/app/pages/pages.module.ts +++ b/src/app/pages/pages.module.ts @@ -1,4 +1,6 @@ import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { CommonModule } from '@angular/common'; import { P404Component } from './404.component'; import { P500Component } from './500.component'; @@ -8,7 +10,12 @@ import { RegisterComponent } from './register.component'; import { PagesRoutingModule } from './pages-routing.module'; @NgModule({ - imports: [ PagesRoutingModule ], + imports: [ + CommonModule, + PagesRoutingModule, + FormsModule, + ReactiveFormsModule, + ], declarations: [ P404Component, P500Component, diff --git a/src/app/pages/register.component.html b/src/app/pages/register.component.html index 20f6f1d..7b7dfe6 100644 --- a/src/app/pages/register.component.html +++ b/src/app/pages/register.component.html @@ -4,6 +4,7 @@
+

Register

Create your account

@@ -32,12 +33,9 @@
- - +
@@ -52,7 +50,8 @@
-
+ +
diff --git a/src/app/pages/register.component.ts b/src/app/pages/register.component.ts index 9ebdb01..aa82935 100644 --- a/src/app/pages/register.component.ts +++ b/src/app/pages/register.component.ts @@ -12,24 +12,27 @@ export class RegisterComponent { signup: FormGroup; ageRanges: Object[]; - constructor(private http: Http, private formBuilder: FormBuilder, private api: ApiService) { - - - this.api.getAgeRanges().subscribe( - result => { - console.log(result); - this.ageRanges = result.ages; - } -) - this.signup = this.formBuilder.group({ - token: ['', [Validators.required]], - full_name: ['', [Validators.required]], - display_name: ['', [Validators.required]], - email: ['', [Validators.required]], - postcode: ['', [Validators.required]], - age_range: ['', [Validators.required]], - password: ['', [Validators.required]], - }); + constructor( + private http: Http, + private formBuilder: FormBuilder, + private api: ApiService + ) { + this.api.getAgeRanges() + .subscribe( + result => { + console.log(result); + this.ageRanges = result.ages; + } + ); + this.signup = this.formBuilder.group({ + token: ['', [Validators.required]], + full_name: ['', [Validators.required]], + display_name: ['', [Validators.required]], + email: ['', [Validators.required]], + postcode: ['', [Validators.required]], + age_range: ['', [Validators.required]], + password: ['', [Validators.required]], + }); } onSubmit() {