'use strict' angular.module('Training').controller('SurveyData',['$scope', '$http', 'TRE022CONTROL', function($scope, $http, TRE022CONTROL){ $scope.formData = {}; $scope.questionData = []; $scope.surveydata = {}; $scope.mylang = ''; $scope.tmpquery = 1; $scope.initLang = function($p_lang){ $scope.mylang = $p_lang; } $scope.initSurvey = function($p_surveyid){ if ($scope.tmpquery == 1){ $scope.getSurveyData($p_surveyid); $scope.tmpquery++; } } $scope.getSurveyData = function($p_surveyid){ TRE022CONTROL.surveyData.queryData({ surveyid: $p_surveyid}) .$promise.then(function(data){ $scope.formData = data.formData; $scope.questionData = data.questionData; console.log($scope.formData); console.log($scope.questionData); }) } $scope.getFormData = function($p_object){ if ($p_object != undefined){ if ($scope.mylang == 'eng'){ return $p_object['eng']; }else if ($scope.mylang == 'tha'){ return $p_object['tha']; } } } $scope.getQuestionData = function($p_object){ if ($p_object != undefined){ if ($scope.mylang == 'eng'){ return $p_object['eng']; }else if ($scope.mylang == 'tha'){ return $p_object['tha']; } } } }]) .directive('showtext', function(){ return { templateUrl: '../EMPVIEW/SHOWTEXTQUESTION.html' }; }) .directive('showchoice', function(){ return { templateUrl: '../EMPVIEW/SHOWCHOICEQUESTION.html' }; }) .directive('showsubquestion', function(){ return { templateUrl: '../EMPVIEW/SHOWSUBQUESTION.html' }; }) .directive('showtable', function(){ return { templateUrl: '../EMPVIEW/SHOWTABLEQUESTION.html' }; });