Açıklama Yok

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var curso = angular.module('curso', []);
  2. // Define the `PhoneListController` controller on the `phonecatApp` module
  3. curso.directive('ngConfirmClick', [
  4. function(){
  5. return {
  6. link: function (scope, element, attr) {
  7. var msg = attr.ngConfirmClick || "Are you sure?";
  8. var clickAction = attr.confirmedClick;
  9. element.bind('click',function (event) {
  10. if ( window.confirm(msg) ) {
  11. scope.$eval(clickAction)
  12. }
  13. });
  14. }
  15. };
  16. }])
  17. curso.controller('CursoController', function CursoController($http, $scope) {
  18. $scope.cursos = [] ;
  19. $scope.operacion = "Añadir" ;
  20. $scope.getCursos = function(){
  21. $http({
  22. method: 'GET',
  23. url: '/list/curso'
  24. }).then(function successCallback(response) {
  25. // this callback will be called asynchronously
  26. // when the response is available
  27. console.log(response.data)
  28. $scope.cursos = response.data;
  29. }, function errorCallback(response) {
  30. // called asynchronously if an error occurs
  31. // or server returns response with an error status.
  32. });
  33. }
  34. $scope.getCursos() ;
  35. $scope.submitForm = function() {
  36. path = "" ;
  37. if($scope.operacion == "Actualizar"){
  38. path = "/updatecourse" ;
  39. }
  40. else{
  41. path = "/addcourse" ;
  42. }
  43. $http.post(path, $scope.curso).success(function(data, status,header, config){
  44. $scope.getCursos() ;
  45. alert(data.response.msg);
  46. }) ;
  47. }
  48. $scope.edit =function(curso){
  49. $scope.curso = curso ;
  50. $scope.operacion = "Actualizar" ;
  51. }
  52. $scope.anadir = function(){
  53. $scope.operacion='Añadir';
  54. $scope.curso={} ;
  55. }
  56. /*
  57. $scope.drop=function(course_academicsesion_id){
  58. $http({
  59. method: 'GET',
  60. url: '/drop?course_academicsesion_id='+course_academicsesion_id
  61. // data: $.param({"codigo" : $scope.selectedProgram})
  62. }).then(function successCallback(response) {
  63. // this callback will be called asynchronously
  64. // when the response is available
  65. if(response.data.response.error == false){
  66. $scope.getAllCoursesInSesion() ;
  67. }
  68. alert(response.data.response.msg);
  69. }, function errorCallback(response) {
  70. // called asynchronously if an error occurs
  71. // or server returns response with an error status.
  72. });
  73. }
  74. */
  75. });