Commit 84446692 by Riina Antikainen

selector WORKING

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