小编ols*_*lsn的帖子

非JSF组件的条件呈现(普通的HTML和模板文本)

我试图有条件地渲染一个<tr>因此我不能使用<h:panelGroup>,因为它将渲染<span> or <div>

我目前的(工作)方法如下:

<h:outputFormat rendered="#{negotiator.maySend}">
    <tr> my tr stuff </tr>
</h:outputFormat>
Run Code Online (Sandbox Code Playgroud)

这是有效的,但我不确定这是否是滥用的方式<h:outputFormat>- 在我使用之前,<h:outputLabel>但这是<label>在IE 中呈现的.

我也已经阅读了这个问题的答案,但如上所述,它们不会对我有用,因为<tr>:如何不在JSF中渲染整个块?

html jsf conditional-rendering

11
推荐指数
1
解决办法
9671
查看次数

RxJS publishReplay与publishLast

我正在Angular应用程序中实现缓存HTTP结果.据我所知,下面的代码都有效,但是我需要知道它们是否完全相同,或者我错过了一些重要的东西?

publishLast

getPosts() {
    if( !this.posts$ ) {
      this.posts$ = this.http.get('api').publishLast().refCount();
      return this.posts$;
    }

    return this.posts$;
  }
Run Code Online (Sandbox Code Playgroud)

publishReplay

getPosts() {
  if( !this.posts$ ) {
    this.posts$ = this.http.get('api').publishReplay(1).refCount();
       return this.posts$;
  }

  return this.posts$;
}
Run Code Online (Sandbox Code Playgroud)

javascript rxjs

7
推荐指数
1
解决办法
2971
查看次数

在RxJS中组合两个对象

我正在使用服务中的rxjs和angular 2.我有一些json,我可以通过get请求访问.

   private _campInfoUrl = 'api/campInfo/campInfo.json';
  constructor(private _http: Http) { }

  getAvailableCamps() {  
    return this._http.get(this._campInfoUrl)
      .map((response: Response) => response.json())
Run Code Online (Sandbox Code Playgroud)

此时我掌握了所有数据.但要进入这个对象

      {
       "search": {
       "startDate": "2016-06-07",
       "endDate": "2016-06-10"
      },
       "reservations": [
       {"campsiteId": 1, "startDate": "2016-06-01", "endDate": "2016-06-04"},
       {"campsiteId": 1, "startDate": "2016-06-11", "endDate": "2016-06-13"},
       {"campsiteId": 2, "startDate": "2016-06-08", "endDate": "2016-06-09"}
  ] 
}
Run Code Online (Sandbox Code Playgroud)

这就是我想要做的

.map((response: Response) => response.json()) // <IProduct[]>
  .map((tripDate) => ({
    reservations: tripDate.reservations,
    newRes: tripDate.search // <-- how to add this to every return object
  }))
Run Code Online (Sandbox Code Playgroud)

我正在努力弄清楚的是rxjs如何在预留数组对象内"搜索"这样的方式 …

javascript arrays json rxjs

5
推荐指数
1
解决办法
1338
查看次数

你如何从 RXJS Observable retryWhen 抛出错误

如果在 3 次尝试后收集不成功,我需要重试一系列 RxJS observables 并抛出序列中项目的错误对象。我发现了这个例子(处理错误的增量退避策略):

var source = get('url').retryWhen(
attempts =>
attempts
  .zip(Observable.range(1, 3), (_, i) => i)
  .flatMap(i => {
    console.log('delay retry by ' + i + ' second(s)');
    return Rx.Observable.timer(i * 1000);
  });
);

var subscription = source.subscribe(
data => {
// Displays the data from the URL or cached data
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)

你如何抛出属于集合中项目的错误?上面的代码似乎吞下了错误,而不是将其呈现给调用者来处理。

rxjs rxjs5

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

错误:服务错误地实现了接口

我正在实现一个接口angular service.我的一个方法返回一个observable array,我想在界面中定义该签名.这就是我试图这样做的方式:

import {Observable} from 'rxjs/Observable';

export interface IItemStore<T> {
    getItems: Observable<Array<T>>;
}

@Injectable
export class ItemStore implements IItemStore<Item>{
    items: Observable<Array<Item>>;
    getItems(): Observable<Array<Item>>{
      return items;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

class `ItemStore` incorrectly implements interface `IItemStore<Item>`. Types of `getItems` are incompatible. Types of property `() => Observable<Item[]>` is not assignable to type `Observable<Item>`. Property `_isScalar` is missing in type `() => Observable<Item[]>`. 
Run Code Online (Sandbox Code Playgroud)

typescript

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

标签 统计

rxjs ×3

javascript ×2

arrays ×1

conditional-rendering ×1

html ×1

jsf ×1

json ×1

rxjs5 ×1

typescript ×1