Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dialogokcancel.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Created by robin on 11/2/15.
  3. */
  4. angular.module('luticate')
  5. .directive('dialogOkCancel', [
  6. function () {
  7. return {
  8. restrict: 'EA',
  9. transclude: true,
  10. templateUrl: 'views/directives/dialogokcancel.html',
  11. link: function link($scope, element, attrs) {
  12. $scope.title = attrs.title;
  13. $scope.model = {};
  14. $scope.pending = false;
  15. $scope.__submit = function()
  16. {
  17. if ($scope.form.$valid) {
  18. $scope.pending = true;
  19. $scope.promise = $scope.submitForm();
  20. if ($scope.promise)
  21. {
  22. $scope.promise.then(function(data) {
  23. if ($scope.onDone) {
  24. $scope.onDone(data);
  25. }
  26. $scope.$dismiss();
  27. $scope.pending = false;
  28. })
  29. .catch(function(error)
  30. {
  31. if ($scope.onError) {
  32. $scope.onError(error);
  33. }
  34. $scope.pending = false;
  35. });
  36. }
  37. else {
  38. $scope.$dismiss();
  39. $scope.pending = false;
  40. }
  41. }
  42. };
  43. $scope.__cancel = function()
  44. {
  45. if ($scope.onCanceled) {
  46. $scope.onCanceled();
  47. }
  48. $scope.$dismiss();
  49. $scope.pending = false;
  50. };
  51. }
  52. };
  53. }]);