angular 2 http api调用下拉列表

时间:2017-02-01 21:19:55

标签: angular

我正在尝试通过调用https://localhost:8080/userapps api动态加载应用程序类型下拉列表,其格式为{“apps”:[“提交”,“悬疑”]。

我没有从以下代码的回复中得到任何回复:

application.service.ts就像

    import { Injectable }     from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';

/**
 * ApplicationService
 */
@Injectable()
export class ApplicationService {
    constructor(private _http: Http) { }

    getapplication(): Observable<any> {
     return this._http.get('https://localhost:8080/userapps')
     .map(res => res.json());
}
}

处理请求的Angular服务就像

     _data: Object;
          constructor(private _application: ApplicationService){}
          getApplication():void {
    this._application.getapplication()
      .subscribe(data => this._data = data,
      error => console.log(error));

 }     

HTML就像:

<div class ="row case-summary-text-row">
 <div [style.width.%]="17" class="dropdown-component margin-right-2">
      <label class="dropdown-label">Applications</label>
      <div class="select-box dropdown-values">
      <select>
      <option *ngFor="let application of apps" value={{application.apps}}></option>

</select>
 </div>
    </div>
    </div>

0 个答案:

没有答案