123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /**
- * Created by robin on 11/2/15.
- */
-
-
- angular.module('luticate')
- .directive('dialogOkCancel', [
- function () {
- return {
- restrict: 'EA',
- transclude: true,
- templateUrl: 'views/directives/dialogokcancel.html',
- link: function link($scope, element, attrs) {
- $scope.title = attrs.title;
- $scope.model = {};
- $scope.pending = false;
-
- $scope.__submit = function()
- {
- if ($scope.form.$valid) {
- $scope.pending = true;
- $scope.promise = $scope.submitForm();
- if ($scope.promise)
- {
- $scope.promise.then(function(data) {
- if ($scope.onDone) {
- $scope.onDone(data);
- }
- $scope.$close(data);
- $scope.pending = false;
- })
- .catch(function(error)
- {
- if ($scope.onError) {
- $scope.onError(error);
- }
- $scope.pending = false;
- });
- }
- else {
- $scope.$close();
- $scope.pending = false;
- }
- }
- };
-
- $scope.__cancel = function()
- {
- if ($scope.onCanceled) {
- $scope.onCanceled();
- }
- $scope.$dismiss();
- $scope.pending = false;
- };
- }
- };
- }]);
|