The service actually get a right value from server (e.g. 1 or 0), but always returned an undefined value when I implemented the service in component. I think the return
statement had just compiled before the .then()
compiled. How can I fix this issue?
private isDuplicateNik(nik: number): boolean{
let count: number;
this.employeeService.isDuplicateNik(nik).then(
res => {
count = res;
}
);
return (count > 0 ? false : true);
}