Commit 80de8094 by Riina Antikainen

Added basic routing

1 parent 0b0a1953
<!--The content below is only a placeholder and can be replaced.-->
<moya-organization></moya-organization>
\ No newline at end of file
<router-outlet></router-outlet>
\ No newline at end of file
import { OrganizationComponent } from './organization/organization.component';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
......@@ -5,6 +6,9 @@ import { AppMockService } from './shared/app.mock.service';
import { AppService } from './shared/app.service';
import { OrganizationModule } from './organization/organization.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
import { NewOrganizationComponent } from './organization/new-organization/new-organization.component';
import { NewEventComponent } from './organization/new-event/new-event.component';
@NgModule({
......@@ -14,7 +18,13 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
imports: [
BrowserModule,
BrowserAnimationsModule,
OrganizationModule
OrganizationModule,
RouterModule.forRoot([
{path: 'new-organization', component: NewOrganizationComponent},
{path: 'organization', component: OrganizationComponent},
{path: 'new-event', component: NewEventComponent},
{path: '', redirectTo: 'organization', pathMatch: 'full'}
], { useHash: true})
],
providers: [{ provide: AppService, useClass: AppMockService}],
bootstrap: [AppComponent]
......
......@@ -6,7 +6,7 @@
<mat-divider [vertical]="true"></mat-divider>
<mat-form-field>
<input matInput placeholder="Address" formControlName="address">
<input matInput required placeholder="Url" formControlName="url">
</mat-form-field>
<button mat-button type="submit">Submit</button>
......
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
@Component({
selector: 'moya-new-event',
......@@ -7,9 +8,21 @@ import { Component, OnInit } from '@angular/core';
})
export class NewEventComponent implements OnInit {
public eventForm = new FormGroup({
name: new FormControl(),
url: new FormControl()
});
constructor() { }
ngOnInit() {
}
onSubmit() {
const values = {
'name': this.eventForm.get('name').value,
'url': this.eventForm.get('url').value,
};
}
}
......@@ -6,12 +6,11 @@
<a style="float:right; font-size:20px; margin-top: 20px" href="#">Moya Login</a>
</div>
<div style="width:50%; float:left">
<h2 style="margin-left: 10px">Tulevat tapahtumat</h2>
<h2 style="margin-left: 10px">Coming events</h2>
<moya-event-list [organisation]="currentOrganisation" style="margin-top:5em;"></moya-event-list>
</div>
<div style="width:50%; float:right">
<h2>Ei omaa organisaatiota?</h2>
<button mat-button (click)="newOrg()">Create new organization</button>
<moya-new-organization></moya-new-organization>
<moya-new-event></moya-new-event>
<a [routerLink]="['/new-organization']"><button mat-button >Create new organization</button></a>
<a [routerLink]="['/new-event']"><button mat-button >Create new event</button></a>
</div>
import { Component, OnInit } from '@angular/core';
import { EventListComponent} from './event-list/event-list.component';
@Component({
selector: 'moya-organization',
......
......@@ -13,6 +13,8 @@ import { ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule, MatDividerModule } from '@angular/material';
import { NewEventComponent } from './new-event/new-event.component';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
......@@ -23,7 +25,8 @@ import { NewEventComponent } from './new-event/new-event.component';
MatInputModule,
MatButtonModule,
MatDividerModule,
FormsModule
FormsModule,
RouterModule
],
providers: [OrganizationListService, EventsService],
declarations: [NewOrganizationComponent, OrganizationListComponent, EventListComponent, OrganizationComponent, NewEventComponent],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!