The value returned by the js function call?

questions are as follows

<input type="text" ng-model="roleName" bg-blur="checkRole(roleName)">
var isCheck = false;
function checkName(roleName) {
    $http({
        url: "http://...",
        type: "post"        
    }).then(function(res){
        isCheck = res.data[0] == 0 ? true : false;
    }, function(err){
        //
    }).then(
        return isCheck;
    );    
}

$scope.checkRole = function (roleName) {
    if(checkName(roleName)) {
       /// 
    }
}

Why is it judged to be undefined in the if (checkName (roleName)) condition, and find the reason?

Mar.02,2021

js is executed asynchronously.
needs to be converted to Synchronize.


$scope.checkRole = function (roleName) {

var a = checkName(roleName);
if(a) {
   /// 
}

}

There is an out-of-step in the

checkName method, so when you call it, it does not return the data you want from the $http. There is no other return in the method, so when there is no return in the method, the method defaults to returning undefined..
if you want this feature, you are recommended to use async await

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf0a69-31d08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf0a69-31d08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?