小编sky*_*ipt的帖子

使用Typescript从Angular 2中的Observable获取项目

我试图从一个服务提供的Angular 2中的一个observable中获取一个项目.到目前为止,我可以订阅observable并查看控制台中的内容,但不能通过它的ID过滤掉项目.我在下面尝试了以下内容,但得到一个空白屏幕.任何提示赞赏.

service.ts:

getJobs() {
  this.observableData = this._http.get('json_path/')
      .map(res => res.json())
      .do(val => {
        this.result = val;
        this.observableData = null;
      })
      .share();
  return this.observableData;
}
Run Code Online (Sandbox Code Playgroud)

component.ts:

let id = this._routeParams.get('id');
this._jobService.getJobs().map(jobs => jobs.filter(item => item.id === id).subscribe(job => this.job = job)[0]);
Run Code Online (Sandbox Code Playgroud)

javascript typescript typescript1.8 angular

4
推荐指数
1
解决办法
5242
查看次数

Make two elements equal height, one with a vertical scroll bar

I am trying to make two sibling div elements the same height. The of them has an overflow-y and a scrollbar with variable height content. The main div has content that is also variable height depending on dynamic content and browser width. The main content div should show all its content. The left scrolling panel should be equal height to the main content and no matter the browser width or height of content, hence the scrolling bar.

Previously, I would …

html css flexbox

2
推荐指数
1
解决办法
1782
查看次数

标签 统计

angular ×1

css ×1

flexbox ×1

html ×1

javascript ×1

typescript ×1

typescript1.8 ×1