I need to create a variable that saves the state of the función
one that I execute in the $interval call $scope.getSignatureCallStatus();
that function executes a request that saves the state in a variable $scope.callStatus = res.data;
... there
are 3 states:
{
success
fail
hangup
}
So if the variable $scope.callStatus = 'success'
that I save in a new variable that value or TRUE
something like $scope.callStatusSucces = $scope.callStatus == 'success'
, but since it is in an interval the value changes dynamically, then I want the new variable not to change the value...
$scope.promise = $interval(function() {
$scope.getSignatureCallStatus();
$scope.showStatus = true;
}, 2500);
This is the function$scope.getSignatureCallStatus();
$scope.getSignatureCallStatus = function() {
$http.get('url', {
params: {
param: param
}
}).then(function(res){
$scope.callStatus = res.data;
});
};
From your question I understand that you only want to know when
$scope.callStatus
'success' has ever been. In this case, you can do the same as you stated in the question: declare a variable$scope.callStatusSucces
(name proposed by you in the question) and assign it true when$scope.callStatus == 'success'
.The function would look like this: