'Angular JS Promise Chaining

I have 2 functions that needs to be sequentially called one after another.Currently the secondFunc is called before the firstFunc completes execution .Any help as to what is wrong in this code would be appreciated .Thank you

driverFunc()
   var deferred=$q.defer();
   var promise=deferred.promise.then($scope.firstFunc()).then($scope.secondFunc());


firstFunc()
   var url="some URL"
   $http.get(url).then(function(data)){
       $scope.resultset=data;
       defer.resolve();
        },function(err){
        defer.reject();
        }
   
    return defer.promise;


secondFunc()
    //$scope.resultset required here

    
        


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source