2017-10-09 6 views
2

setInervalウィンドウを使用して

.controller('overviewCtrl', function ($scope, $http, $interval) { 
 
     $scope.cardShow = false; 
 
     $scope.infoShow = true; 
 
     $scope.yes1 = false; 
 
     $scope.yes2 = false; 
 
     $scope.status = true; 
 
     $scope.arbitration = true; 
 
     $scope.notAccepted = true; 
 
     $scope.cardShowRegular = false; 
 
     $scope.check1 = false; 
 
     $scope.id = 53; 
 
     $scope.opportunitiesArr = []; 
 
     $scope.opportunity = []; 
 
     $scope.profile = []; 
 
     /*getting opportunities*/ 
 

 
     $scope.oppList = function() { 
 
      $http.get("https://serviceme.blynksystems.com:6443/createContract/fseoppurtunities/" + $scope.id) 
 
       .then(function (response) { 
 
        $scope.opportunitiesArr = response.data; 
 
        console.log("opportunities " + JSON.stringify($scope.opportunitiesArr)); 
 
       }, function (response) { 
 
        console.log("error" + response); 
 
       }); 
 
     } 
 

 
     /*$rootScope.$broadcast("sendOpportunities", $scope.opportunitiesArr);*/ 
 
     $scope.oppList(); 
 
     /*end of getting opportunities*/ 
 
     $scope.contactInfo = function (opport) { 
 
      $scope.opportunity = opport; 
 
      console.log("opportfjdufiu" + JSON.stringify($scope.opportunity)); 
 
      console.log("opport " + JSON.stringify(opport)); 
 
      /*$scope.customerId = opport.customer_id;*/ 
 
      /*$scope.serviceName = opport.service_name; 
 
      $scope.carModel = opport.car_model;*/ 
 
      /*$scope.driverEmail = opport.driver_email;*/ 
 
      /*$scope.statusOfFse = opport.status_of_fse;*/ 
 
      $scope.cardShow = true; 
 
      $scope.cardShowRegular = true; 
 
      $scope.infoShow = false; 
 
      /*posting the acceptance*/ 
 
      if (opport.driver_email != null || opport.driver_email != undefined) { 
 
       var data = { 
 
        "mechanic_id": $scope.id, 
 
        /*"customer_id": opport.customer_id,*/ 
 
        "driver_email": opport.driver_email, 
 
        "service_name": opport.service_name, 
 
        "car_model": opport.car_model, 
 
        "status": 2, 
 
        "counter_price_fse": "" 
 
       } 
 
      } else { 
 
       var data = { 
 
        "mechanic_id": $scope.id, 
 
        "customer_id": opport.customer_id, 
 
        /*"driver_email": opport.driver_email,*/ 
 
        "service_name": opport.service_name, 
 
        "car_model": opport.car_model, 
 
        "status": 2, 
 
        "counter_price_fse": "" 
 
       } 
 
      } 
 
      console.log("emergency" + JSON.stringify(data)); 
 
      var req = { 
 
       method: 'POST', 
 
       url: 'https://serviceme.blynksystems.com:6443/createContract/updatewhenfseaccepted', 
 
       data: data 
 
      } 
 
      $http(req).then(function (response) { 
 
       console.log("respose" + JSON.stringify(response.data)); 
 
      }, function (response) { 
 
       console.log(response); 
 

 
      }); 
 
      $scope.callFtn = function() { 
 
    setInterval($scope.contactInfo(opport), 3000); 
 
} 
 
$scope.callFtn(); 
 
      /*$interval(function() { 
 
    $scope.contactInfo(opport) 
 
}, 3000);*/ 
 
      /*posting the acceptance*/ 
 

 
     } 
 
     });

をぶら下げている間に私は、イオンproject.Iに取り組んでいます私が使用していますserver.Forから来ている応答では5秒後にすべての状態を確認する必要がありますこの問題を解決するにはどうすればいいですか?

+0

どんなエラーが発生しましたか? '$ interval'もうまくいくはずです。何かが失敗したように見える –

+0

$ intervalも使用しましたが、contactInfo関数のiamはdivタグを1つ表示しています。 –

答えて

0

あなたは結局setIntervalを再帰的に使用しています立ち往生するための窓。代わりの解決方法は、https://stackoverflow.com/a/18687829/1912288を参照してください。

$intervalをAngularで使用すると、$intervalが呼び出されてスコープの変更が検索され、バインディングの変更が反映されます。これは、ダイジェストサイクルをトリガーすることによって行われます。

+0

ありがとうございます。$インターバルで関数のcontactInfoが呼び出していますが、関数内のPOSTリクエストが呼び出されていません.contentInfoがPOST要求コンソールを除く3秒ごとに呼び出しているときに、関数内のコンソールが印刷を行っているとき、成功のブロック。 –

関連する問題