ich versuche, eine Folie von Fragen mit eckigen js $ Timeout-Funktion zu erstellen, konnte ich es implementieren und es funktioniert gut, aber wenn ich es versuche um die Folie zu aktualisieren, damit sie erneut starten kann, funktioniert die Aktualisierung nur für die ersten Folien, da die anderen Folien nicht mit der Zeitverzögerung funktionieren Hier ist mein Code unten, die Hauptfunktion und die Rückruffunktion.
$scope.callTime = function() {
q_len = questions.length;
$timeout(function() {
//checking if the question index is still valid
if (q_indy < q_len) {
slides = questions[q_indy].pictures;
len = slides.length;
console.log(indy);
$scope.currentQuestion = questions[q_indy];
f_time = parseInt(slides[indy].time_frame);
//getting the specific time needed to run this particular slide
r_time = f_time - initialTime;
if (indy < len) {
f_time = parseInt(slides[indy].time_frame);
var interval = slides[indy].picture_url;
indy++;
console.log(q_indy + " " + indy + " " + r_time);
//changing to the current picture so it can run for the given time
$scope.image = $scope.url.url + interval;
if (indy == len) {
//checking if the question's slides is out of index so the next question should be loaded
q_indy++;
indy = 0;
initialTime = f_time;
console.log(q_indy + " " + indy + " " + r_time);
$scope.callTime();
}
else {
//if the slide index is active the next slide should be loaded then
initialTime = f_time;
$scope.callTime();
}
//console.log($scope.url.url + interval);
}
}
}, r_time);
//time();
}
$scope.refresh = function() {
$timeout.cancel($scope.callTime);
q_indy = 0;
indy = 0;
initialTime = 0;
r_time = 0;
len = 0;
q_len = 0;
$scope.callTime();
var e = document.getElementById('myTune');
//e.pause();
e.currentTime = 0;
//e.play;
};
Vielen Dank ... das hat funktioniert, ich habe nur die Timeout-Funktion in der Timer-Variable eingepackt und voila hat funktioniert – itsdenty