问题
I'm creating a quiz, every second needs to be answered in 30 seconds so I want to create a progressbar to show this to the user. When the 30 seconds are over, an alert needs te be popped up en the next question needs to appear.
Does someone have any idea how to start with this? Or any good tutorial? I didn't find anything interesting.
my controller code looks like this:
lycheeControllers.controller('quizCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get('json/questions.json').success(function (data) {
//all questions
$scope.questions = data;
//filter for getting answers / question
$scope.ids = function (question) {
return question.id == number;
}
$scope.buttonText = "Next question";
$scope.next = function () {
if (!(number == (data.length))) {
if (number + 1 == (data.length)) {
$scope.buttonText = "Get results";
}
number++;
if (correct == true) {
points++;
}
//alert(points);
} else {
alert("Quiz finished: your total score is: " + points);
}
}
$scope.checked = function (answer) {
//alert(answer.answer);
if (answer.correct == "yes") {
correct = true;
} else {
correct = false;
}
//alert(correct);
}
});
}]);
回答1:
I was really interested in this and hacked a solution, that you could use as a startingpoint. It is already quite complete, so just have a look and get inspired.
http://jsfiddle.net/rGWUR/7/
merry christmas :)
来源:https://stackoverflow.com/questions/20774833/angular-progress-bar-controller