How to deal with nested promises in javascript angularJS

Function 2 is using Function 1 return while Function 3 uses both returns, how to do cleanly ?
Function 3 is only returning me undefined values right nom.

Here are my 3 functions.

Function1

$scope.nombreCompetencesATraiter = function(){
var nbr = 0;
        notesService.getNotesByCollaborateurId($scope.idCollaborateurSelectionne).then(function(data){
            $scope.myNotes = data;
            angular.forEach($scope.myNotes, function(valueNote, keyNote) {
                if ((valueNote.status === "EN_ATTENTE_DE_VALIDATION") || (valueNote.status === "EN_ATTENTE_DE_SUPPRESSION")){
                    nbr++;
                }
            })
            console.log(nbr);
            return nbr;
        })
    }

Function 2

$scope.affinerConfigBoutonsCompetences = function() {
        nbCompetenceATraiter = $scope.nombreCompetencesATraiter();
        if (nbCompetenceATraiter == 0){
            $scope.radioModelFilterToutesLesCompetences = true;
            $scope.radioModelFilterCompetencesAValider = false;
        }
        else{
            $scope.radioModelFilterCompetencesAValider = true;
            $scope.radioModelFilterToutesLesCompetences = false;
        }
    }

Function 3

$scope.affinerConfigBoutonsCompetencesThen = function(){
        $q.all([$scope.nombreCompetencesATraiter(), $scope.affinerConfigBoutonsCompetences()]).then(function(value) {
            console.log(value[0]);
            console.log(value[1]);
        })
    }

Thanks a lot.

Source: AngularJS