Mercurial > hg > ng2-query-ismi
view 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 source
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="#mode of queryModes" [value]="mode.id"> {{mode.label}} </option> </select> <select [(ngModel)]="selectedQuery"> <option *ngFor="#option of query2Options" [value]="option"> {{option}} </option> </select> `, providers: [QueryService, HTTP_PROVIDERS] }) export class QuerySelectComponent implements OnInit { public queryModes; public selectedQuery = 'unknown'; 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._queryService.getQueryOptions(selected).then( options => this.query2Options = options); } }