Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('my_app', [])
- app.controller('my_con', ['$scope', '$http', function($scope, $http) {
- $scope.save = function(sector) {
- var del_status = $scope.is_exist(sector);
- console.log(del_status); // is_exsis return value
- if(!del_status) {
- // save
- }
- }
- $scope.is_exist = function(sector) {
- $http({
- method : 'POST',
- url : '/is_data_exist',
- contentType : 'application/json; charset=utf-8',
- data : angular.toJson({
- 'sector': sector
- }),
- dataType: 'json',
- }).then(function successCallback(response) {
- console.log(response.data); //http respond
- if(response.data == 'False') {
- return false;
- }
- else {
- return true;
- }
- })
- }
- }])
- var del_status = $scope.is_exsis(function(data){
- console.log(del_status); // is_exsis return value
- if(!del_status) {
- // save
- }
- });
- $scope.save = function(sector) {
- $scope.is_exsis(sector).then(function(del_status){
- console.log(del_status); // is_exsis return value
- if(!del_status) {
- // save
- }
- });
- }
- $scope.is_exist = function(sector) {
- return $http({
- method : 'POST',
- url : '/is_data_exist',
- contentType : 'application/json; charset=utf-8',
- data : angular.toJson({
- 'sector': sector
- }),
- dataType: 'json',
- }).then(function successCallback(response) {
- console.log(response.data); //http respond
- if(response.data == 'False') {
- return false;
- }
- else {
- return true;
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement