大家好,每个人都可以帮助我....... 我试图将var declare作为global&在angularJS
中的$ scope.funcName中计算1。 HTML
{{totalmarks}}
2。控制器
var next = 0;
var marks = 0;
var total;
$http.get('../js/commonquiz.json').success(function(res){
$scope.myData = res;
jsonData = $scope.myData;
noOfQuestion = jsonData.length;
$scope.currentQ = jsonData[next];
}).error(function (err){
console.log(err);
});
$scope.change_question = function(selected,option,index){
var rightAns = $scope.currentQ.result //Get Result value
if (index == rightAns){ //compare selected value with rightANS
$scope.rightOption = index;
marks = marks + 1;
total = marks;
}
}
$scope.totalmarks = total;