Commit 84446692 by Riina Antikainen

selector WORKING

1 parent 40dac320
<!--The content below is only a placeholder and can be replaced.-->
<div>
<moya-organization-list style="float:top, left;"></moya-organization-list>
<moya-organization-list (selected)="onOrganizationChange($event)" style="float:top, left;"></moya-organization-list>
<h1 style="text-align:center; margin-left:25%; display:inline-block">
Welcome to {{ title }}!
</h1>
......@@ -13,9 +13,5 @@
<div style="width:50%; float:right">
<h2>Ei omaa organisaatiota?</h2>
<button (click)="newOrg()">Luo uusi organisaatio</button>
<moya-new-organization></moya-new-organization>
</div>
<<<<<<< HEAD
<moya-organization-list></moya-organization-list>
<moya-event-list></moya-event-list>
=======
>>>>>>> ba42812ec6cdee25062402ba6d95b939c43ed534
......@@ -8,8 +8,12 @@ import { AppService } from './shared/app.service';
})
export class AppComponent {
title = 'Moay';
public currentOrganisation = 'insomnia';
public currentOrganisation: string;
constructor(private appService: AppService) {
console.log(this.appService.get());
}
onOrganizationChange(event) {
this.currentOrganisation = event;
}
}
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { EventsService } from './event-service.service';
import { OnChanges } from '@angular/core/src/metadata/lifecycle_hooks';
@Component({
selector: 'moya-event-list',
templateUrl: './event-list.component.html',
styleUrls: ['./event-list.component.scss']
})
export class EventListComponent implements OnInit {
export class EventListComponent implements OnInit, OnChanges {
@Input() organisation: string;
public events: any;
constructor(private appService: EventsService) {
this.events = (this.appService.get(this.organisation));
}
onClick() {
......@@ -19,6 +19,12 @@ export class EventListComponent implements OnInit {
}
ngOnInit() {
console.log(this.organisation);
this.events = this.appService.get(this.organisation);
}
ngOnChanges(changes: SimpleChanges): void {
console.log(changes);
this.events = this.appService.get(changes.organisation.currentValue);
}
}
......@@ -4,7 +4,8 @@ import { Injectable } from '@angular/core';
export class EventsService {
get(org: String) {
if (org === 'asm') {
console.log(org);
if (org === 'Assemly') {
return [
{title: 'Assembly Winter 18', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Summer 18', date: '1.2.2018 - 3.2.2018'},
......
......@@ -13,7 +13,7 @@ export class OrganizationListComponent implements OnInit {
public selectedValue: string;
@Output()
ngModelChange = new EventEmitter();
selected = new EventEmitter();
public organizations = [
{name: 'Assemly Organization'},
......@@ -26,6 +26,7 @@ export class OrganizationListComponent implements OnInit {
}
onChange() {
this.selected.emit(this.selectedValue);
}
ngOnInit() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!