Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. var app = angular.module('my_app', [])
  2. app.controller('my_con', ['$scope', '$http', function($scope, $http) {
  3.  
  4. $scope.save = function(sector) {
  5. var del_status = $scope.is_exist(sector);
  6.  
  7. console.log(del_status); // is_exsis return value
  8.  
  9. if(!del_status) {
  10. // save
  11. }
  12. }
  13.  
  14. $scope.is_exist = function(sector) {
  15. $http({
  16. method : 'POST',
  17. url : '/is_data_exist',
  18. contentType : 'application/json; charset=utf-8',
  19. data : angular.toJson({
  20. 'sector': sector
  21. }),
  22. dataType: 'json',
  23. }).then(function successCallback(response) {
  24.  
  25. console.log(response.data); //http respond
  26.  
  27. if(response.data == 'False') {
  28. return false;
  29. }
  30. else {
  31. return true;
  32. }
  33. })
  34. }
  35. }])
  36.  
  37. var del_status = $scope.is_exsis(function(data){
  38. console.log(del_status); // is_exsis return value
  39.  
  40. if(!del_status) {
  41. // save
  42. }
  43. });
  44.  
  45. $scope.save = function(sector) {
  46. $scope.is_exsis(sector).then(function(del_status){
  47.  
  48. console.log(del_status); // is_exsis return value
  49.  
  50. if(!del_status) {
  51. // save
  52. }
  53. });
  54.  
  55. }
  56.  
  57. $scope.is_exist = function(sector) {
  58. return $http({
  59. method : 'POST',
  60. url : '/is_data_exist',
  61. contentType : 'application/json; charset=utf-8',
  62. data : angular.toJson({
  63. 'sector': sector
  64. }),
  65. dataType: 'json',
  66. }).then(function successCallback(response) {
  67.  
  68. console.log(response.data); //http respond
  69.  
  70. if(response.data == 'False') {
  71. return false;
  72. }
  73. else {
  74. return true;
  75. }
  76. })
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement