'use strict' angular.module('EXAM').controller('Exam003Add', ['$scope', '$http', 'EXAMSERVICES', '$window', function($scope, $http, EXAMSERVICES, $window){ $scope.questset4 = []; EXAMSERVICES.ManageExam003.query({examid: '0', querytype: 'ex04'}) .$promise.then(function(data){ $scope.questset4 = JSON.parse(data.result); console.log($scope.questset4); }); $scope.renderHtml = function(strobj, parent_index, index){ $('#ren'+parent_index+""+index).html(strobj); //return strobj; } $scope.checkSelect = function(){ var arrresult = []; $scope.questset4.forEach(function(data){ if (data.ischeck != undefined && data.ischeck == true){ arrresult.push({ questionid: data.questionset4id, question_name: data.questionset4_name, question_body: data.questset4data, score: data.total_score }); } }); return arrresult; }; $scope.add = function () { var result = $scope.checkSelect(); $window.opener.putNewChild(result); $window.close(); } $scope.selectAll = function(){ $scope.questset4.forEach(function(data){ data.ischeck = true; }); }; $scope.deSelectAll = function(){ $scope.questset4.forEach(function(data){ data.ischeck = false; }); }; }]);