Commit b3eaa941 by Riina Antikainen

New event buttons works

1 parent d3586d07
......@@ -16,7 +16,7 @@ export class EventListComponent implements OnInit, OnChanges {
}
onClick() {
console.log('Nappitoimii');
console.log('Button works');
}
ngOnInit() {
......@@ -26,7 +26,8 @@ export class EventListComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges): void {
console.log('toimii', changes, this.organization.name);
this.events = this.appService.get(changes.organization.currentValue);
this.events = this.appService.get(this.organization.name);
// this.events = this.appService.get(changes.organization.currentValue);
console.log('ei toi');
}
}
......@@ -5,7 +5,7 @@ export class EventsService {
get(org: String) {
console.log(org);
if (org === 'Assemly') {
if (org === 'Assembly') {
return [
{title: 'Assembly Winter 18', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Summer 18', date: '1.2.2018 - 3.2.2018'},
......
<form [formGroup]="eventForm" (ngSubmit)="onSubmit()">
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<mat-form-field>
<input matInput required placeholder="Event name" formControlName="name">
</mat-form-field>
......@@ -9,5 +9,6 @@
<input matInput required placeholder="Url" formControlName="url">
</mat-form-field>
<button mat-button (click)='onSubmit()'>Submit</button>
<button mat-button type="submit" [disabled]="!form.valid">Submit</button>
<button mat-button (ngClick)="goBack()">Back</button>
</form>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { FormControl, FormGroup, FormBuilder, Validators} from '@angular/forms';
import { Router } from '@angular/router';
@Component({
......@@ -9,22 +9,27 @@ import { Router } from '@angular/router';
})
export class NewEventComponent implements OnInit {
public eventForm = new FormGroup({
name: new FormControl(),
url: new FormControl()
});
form: FormGroup;
constructor(private _router: Router) { }
constructor(private formBuilder: FormBuilder, private _router: Router) { }
ngOnInit() {
this.form = this.formBuilder.group({
name: [null, Validators.required],
url: [null, Validators.required]
});
}
onSubmit() {
const values = {
'name': this.eventForm.get('name').value,
'url': this.eventForm.get('url').value,
'name': this.form.get('name').value,
'url': this.form.get('url').value
};
this._router.navigate(['/organization']);
}
goBack() {
this._router.navigate(['/organization']);
}
}
......@@ -18,7 +18,7 @@ export class OrganizationListComponent implements OnInit {
public organizations: Organization[] = [
{id: 1, name: 'Assembly Organization'},
{id: 3, name: 'Assemly'},
{id: 3, name: 'Assembly'},
{id: 30, name: 'Organization'}
];
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!