angular progress-bar controller

梦想与她 提交于 2019-12-25 06:55:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!