検索入力ボックスがあるホームページがあり、結果を表示する別のページにルーティングします。その結果のページには、返された観測可能性(searchResult)をループする* ngForがあります。Observableが空になったときに便利な情報を表示したい
私は<div *ngIf="searchResult">
を持っています。これは、観測値が空であるかどうかを示しています。ただし、ホームページから結果ページにコンポーネントが初期化されると、このdivはすぐに読み込まれ、検索結果が返された後に消えます。 Observableが空であるかどうかを調べるもう1つの方法はありますか?このため、* ngIf = "searchResult"を使用する代わりにブール値を使うことができます。ここ
getDocument(searchText:string) {
this._contractService.getDocument(searchText)
.subscribe(
document => this.document = document,
error => this.errorMessage = <any>error);
}
私* ngIfです:
<div id="search-not-found" class="col-xs-12" *ngIf="!searchResult">
<div class="alert alert-success" role="alert"><p>Sorry, we did not find any match related to your search"</p></div>
</div>
私は感謝したい任意のヘルプは
は、ここに私のサブスクリプションです。ありがとう