sony web sony web - 2 months ago 16
AngularJS Question

how to run function in one controller?

This is my controller

.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();
})


How to run function in one controller like above..?

Answer

You can call the function to be executed next as follows:

.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();
})
Comments