2016-09-18 5 views
0

하나의 컨트롤러에서 기능을 실행하는 방법은 무엇입니까?

.controller('tanyaCtrl', function($rootScope, $ionicPopup, tanyaService, $state) { 

    $rootScope.hal=1; 
    $rootScope.klikBerikutnya = function() { 
     $rootScope.hal=$rootScope.hal+1; 
     //how to run next function after this code..? 
    } 

    //next function 
    $rootScope.showData = function() { 
    tanyaService.getApiTanya($rootScope.getPilihSubTest, $rootScope.hal).success(function(dataAmbil){ 
     $rootScope.Questions = dataAmbil; 
    }); 
    }; 
    $rootScope.showData(); 
}) 

어떻게 위와 같이 하나의 컨트롤러 기능을 실행하는 내 컨트롤러입니다 ..?

다음과 같이 함수를 호출 할 수 있습니다

답변

0

다음에 실행되는 :

.controller('tanyaCtrl', function($rootScope, $ionicPopup, tanyaService, $state) { 

$rootScope.hal=1; 
$rootScope.klikBerikutnya = function() { 
    $rootScope.hal=$rootScope.hal+1; 
    //how to run next function after this code..? 
    //just call the function here as follows: 
    $rootScope.showData(); 
} 

//next function 
$rootScope.showData = function() { 
tanyaService.getApiTanya($rootScope.getPilihSubTest, $rootScope.hal).success(function(dataAmbil){ 
    $rootScope.Questions = dataAmbil; 
}); 
    }; 
    $rootScope.showData(); 
}) 
관련 문제