【发布时间】:2017-10-01 12:46:48
【问题描述】:
我想返回布尔值(只有 true 或 false),其中我的函数的返回类型是 Observable 。如何在使用 angular 2 时只返回真值或假值。我尝试了很多但无法解决这个问题。我该怎么做?
下面是我的代码:
CheckValidation(measurementUnitId: string, itemId: string): Observable<boolean> {
const url = `api/v1.0/measurementUnits/${measurementUnitId}/items/${itemId}`;
debugger;
var returnValue = this.http.get(url)
.do(result => console.log('CheckValidation: ' + result))
.catch(this.handleError);
//Here I need the value of returnValue variable will be true or false.
}
提前致谢。
【问题讨论】:
-
你不能,你能告诉我们
CheckValidation是如何使用的。
标签: angular angular2-services angular2-directives