bir mantıksal değeri:angularjs 2 ZoneAwarePromise Bu yöntem ile API verileri ile restClient için angularjs 2'deki bir temel sınıf
export class InfoDataBoolean {
public data: boolean;
public error: string;
}
: InfoDataBoolean iki özelliğe sahip bir sınıftır
public getInfoDataBooleanRequest(url: string): InfoDataBoolean {
return this.http.get(this.urlApiPrefix + url, this.createRequestOptions())
.toPromise()
.then(response => <InfoDataBoolean>response.json())
.catch(this.handleError);
}
Hizmet yöntemimi aradığım başka bir sınıf var. Bu çağrı, InfoDataBoolean'daki verileri döndürmek istediğim bir yöntem içinde, bunun gibi InfoDataBoolean sınıfının değil.
public isLogged(): boolean {
return this.getInfoDataBooleanRequest('islogged').then(x => {
let result: InfoDataBoolean = x;
if(result.error !== "1") {
console.log('Success is failed');
return false;
}
return result.data;
});
}
console.log(isLogged())
çıktısı:
ZoneAwarePromise {__zone_symbol__state: null, __zone_symbol__value: Array [0]}
Ama benim yöntemiyle isLogged()
den true
veya false
dönmek istiyorum.
Bunu nasıl yapabilirim?