Mercurial > hg > ng2-query-ismi
diff app/query-select.component.ts @ 1:59b7c3afcc6b
first interface and http request.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 11 Jan 2016 19:25:53 +0100 |
parents | 39ec75917ef7 |
children | c741a00d38de |
line wrap: on
line diff
--- a/app/query-select.component.ts Thu Jan 07 15:04:15 2016 +0100 +++ b/app/query-select.component.ts Mon Jan 11 19:25:53 2016 +0100 @@ -1,31 +1,47 @@ -import {Component} from 'angular2/core'; +import {Component, OnInit} from 'angular2/core'; +import {HTTP_PROVIDERS} from 'angular2/http'; + +import {QueryService} from './query.service'; +import {QueryMode} from './query-mode'; + @Component({ selector: 'query-select', template: ` <p>Selected option: {{selectedQuery}}</p> <select (change)="onSelectType($event)"> - <option *ngFor="#option of queryTypes" [value]="option"> - {{option}} + <option *ngFor="#mode of queryModes" [value]="mode.id"> + {{mode.label}} </option> </select> <select [(ngModel)]="selectedQuery"> - <option *ngFor="#option of query2Types" [value]="option"> + <option *ngFor="#option of query2Options" [value]="option"> {{option}} </option> </select> - ` + `, + providers: [QueryService, HTTP_PROVIDERS] }) -export class QuerySelectComponent { - public queryTypes = ['Object type is', 'Attribute contains']; + +export class QuerySelectComponent implements OnInit { + public queryModes; public selectedQuery = 'unknown'; - public query2Types = ['a', 'b', 'c']; + public query2Options; + + constructor(private _queryService: QueryService) {} + + ngOnInit() { + this.setupQueryModes(); + } + + setupQueryModes() { + this.queryModes = this._queryService.getQueryModes(); + this._queryService.getIsmiObjectTypes(); + } onSelectType(event: any) { - var selected = event.target.value - this.selectedQuery = selected; - if (selected == 'Attribute contains') { - this.query2Types = ['d', 'e', 'f']; - } + var selected = event.target.value; + this._queryService.getQueryOptions(selected).then( + options => this.query2Options = options); } }