我不能从功能获得烫发! 这里存在范围问题JavaScript范围,烫发不能得到正确的变量
var perm = "none";
var participantsPromise = getChannelParticipants(peerID * -1).then(
function (participants) {
angular.forEach(participants, function (participant){
if (participant.user_id == UserID) {
switch (participant._) {
case "channelParticipant":
perm = "normal";
console.log('->>>>>>> Perm = normal');
break;
case "channelParticipantEditor":
perm = "Admin";
console.log('->>>>>>> Perm = Admin');
break;
case "channelParticipantModerator":
perm = "Admin";
console.log('->>>>>>> Perm = Admin');
break;
case "channelParticipantCreator":
perm = "Creator";
console.log('->>>>>>> Perm = Creator');
break;
default:
console.log('#########> No handler for', participant._);
perm = "unknown";
}
}
})
});
return perm;
函数返回无,但烫发已经设置其他值。 我能做什么?
请参阅[我的回答(http://stackoverflow.com/a/39742108/2545680) –