123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- var curso = angular.module('curso', []);
-
- // Define the `PhoneListController` controller on the `phonecatApp` module
-
- curso.directive('ngConfirmClick', [
- function(){
- return {
- link: function (scope, element, attr) {
- var msg = attr.ngConfirmClick || "Are you sure?";
- var clickAction = attr.confirmedClick;
- element.bind('click',function (event) {
- if ( window.confirm(msg) ) {
- scope.$eval(clickAction)
- }
- });
- }
- };
- }])
-
- curso.controller('CursoController', function CursoController($http, $scope) {
-
- $scope.cursos = [] ;
- $scope.operacion = "Añadir" ;
-
- $scope.getCursos = function(){
-
- $http({
- method: 'GET',
- url: '/list/curso'
- }).then(function successCallback(response) {
- // this callback will be called asynchronously
- // when the response is available
- console.log(response.data)
-
- $scope.cursos = response.data;
- }, function errorCallback(response) {
- // called asynchronously if an error occurs
- // or server returns response with an error status.
- });
- }
-
- $scope.getCursos() ;
-
- $scope.submitForm = function() {
-
- path = "" ;
- if($scope.operacion == "Actualizar"){
- path = "/updatecourse" ;
- }
- else{
- path = "/addcourse" ;
- }
- $http.post(path, $scope.curso).success(function(data, status,header, config){
- $scope.getCursos() ;
- alert(data.response.msg);
- }) ;
- }
-
- $scope.edit =function(curso){
- $scope.curso = curso ;
- $scope.operacion = "Actualizar" ;
- }
- $scope.anadir = function(){
- $scope.operacion='Añadir';
- $scope.curso={} ;
- }
- /*
- $scope.drop=function(course_academicsesion_id){
- $http({
- method: 'GET',
- url: '/drop?course_academicsesion_id='+course_academicsesion_id
- // data: $.param({"codigo" : $scope.selectedProgram})
- }).then(function successCallback(response) {
- // this callback will be called asynchronously
- // when the response is available
- if(response.data.response.error == false){
- $scope.getAllCoursesInSesion() ;
- }
- alert(response.data.response.msg);
- }, function errorCallback(response) {
- // called asynchronously if an error occurs
- // or server returns response with an error status.
- });
- }
- */
-
- });
|