【发布时间】:2018-06-05 00:46:36
【问题描述】:
无法在 html(视图)中重新加载数据
它仅在第一次加载(页面加载)时正常加载,在按钮单击时它不会反映更改,尽管控制器具有正确的记录。
查看-
<div class="well" ng-app="myQuizApp"> <fieldset ng-repeat="Question in ::qstns">
</fieldset> </div>
<button type="button" class="btn btn-primary btn-lg btn-block" ng-click="Load_Quizes('2')">Review</button>
Anguar js 库在此处引用 1.6
myApp.controller("myQuizs", function ($scope, angularService, $window, $sce,$interval) {
var action = 'qiz1';
Load_Quizes(1); // Triggering page load (working fine)
// While calling the function in button click , it gets triggered and contains correct data but ng-repeat does not updates (holds old records) .
function Load_Quizes(qtnserial) {
var getQuzData = angularService.LoadQuizes(action, qtnserial);
getQuzData.then(function (response) {
try {
//LOAD QUESTION CHOICE
if (response.data != null) {
debugger;
$scope.Quiz = response.data;
if ($scope.Quiz.Quiz_id > 0) {
$scope.qst_toask = $scope.Quiz.Quiz_Name.split('"').join('');
$scope.qstns = $scope.Quiz.QuizQuestiones;
} else {
$window.alert("Online mock test / Quiz does not exists.");
}
}
else {
$window.alert("Online mock test / Quiz does not exists.");
}
}
catch (e) {
$window.alert('Quiz response error.');
}
}, function () {
alert('Error in getting records.');
});
}
请帮忙。 谢谢。
【问题讨论】:
-
ng-click="Load_Quizes('2')"
标签: jquery angularjs angularjs-scope