angular-if语句中未执行的代码块

时间:2019-06-24 02:54:05

标签: javascript

我有一段代码用于检查是否存在重复的号码。如果是这样,它将不会将数据保存到数据库中,但是当满足条件时,在Chrome调试中,不会执行行:return,而是跳转到isSaving = true行。我该如何解决?

checkFloorNumber(buildingId: any) {
    if (buildingId !== undefined) {
        this.buildingService.findAllFloors(buildingId).subscribe((res: 
        HttpResponse<IFloor[]>) => {
            let floors = res.body;

            for (let i = 0; i < floors.length; i++) {
                if (floors[i].floorNumber == this.floor.floorNumber) {
                    //this.floor.floorNumber = null;
                    this.isDuplicate = true;
                    break;
                }
            }
        });
    }
}

save() {
    this.checkFloorNumber(this.floor.buildingId);
    if(this.isDuplicate === true) {
        console.log("asd");
        return;    
    }

    this.isSaving = true;
}

0 个答案:

没有答案