eval.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) } }); } }; }]); eval.controller('evalController', function evalController($http, $scope){ $scope.evaluaciones = evaluaciones $scope.operacion = "Añadir" ; var teacherId = document.getElementById('maestroId').value; var ofertaId = document.getElementById('ofertaId').value; $scope.submitForm = function() { path ="/Maestro/"+teacherId+"/" +ofertaId; if ($scope.operacion =="Actualizar"){ path += "/editar" } else{ path += "/addNota" } $http.post(path, $scope.eval); } $scope.edit = function(key){ $scope.eval = evaluaciones[key]; $scope.operacion ='Actualizar'; } $scope.anadir = function (){ $scope.eval = {}; $scope.operacion = 'Añadir'; } });