首页 > 解决方案 > 为什么按钮事件在第三次点击后停止?

问题描述

我有这个网站: http: //www.panelatlantik.com/foodx/index.html

例如找到数字 133 并单击。

您将在右侧看到一个新的彩色按钮。单击并等待 2 秒。我会改变的。再次单击等待 2 秒。它会再次改变。伟大的!但是下一次点击不起作用。我做错了什么?

 <tr>
    <td colspan="2" ng-if="pin3.status=='Yeni'">
        <button ng-click="gYap(pin3.orderid)" style="width: 100%" class="btn btn-success">PREPARING</button>
    </td>
</tr>

<tr>
    <td colspan="2" ng-if="pin3.status=='Gönderildi'">
        <button ng-click="iYap(pin3.orderid)" style="width: 100%" class="btn btn-success">SENT</button>
    </td>
</tr>

<tr>
    <td colspan="2" ng-if="pin3.status=='İptal'">
        <button ng-click="gAl(pin3.orderid)" style="width: 100%" class="btn btn-info">CANCELLED</button>
    </td>
</tr>


    $scope.gYap = function(param){
        $http.get("php/makine.php?komut=gYap&id="+param).then(function(response) {
         $scope.gYap = response.data;}) 
         $timeout( function(){
            $scope.hepsi();
    }, 1000 );

    $timeout( function(){
        $scope.siparisgetir(param);
    }, 2000 );

         }

         $scope.iYap = function(param){
        $http.get("php/makine.php?komut=iYap&id="+param).then(function(response) {
         $scope.iYap = response.data;})  
         $timeout( function(){
            $scope.hepsi();
    }, 1000 );

    $timeout( function(){
        $scope.siparisgetir(param);
    }, 2000 ); }

         $scope.gAl = function(param){
        $http.get("php/makine.php?komut=gAl&id="+param).then(function(response) {
         $scope.gAl = response.data;})  
         $timeout( function(){
            $scope.hepsi();
    }, 1000 );

    $timeout( function(){
        $scope.siparisgetir(param);
    }, 2000 ); 
         }

标签: angularjs

解决方案


第三次点击后我收到了

v2.gYap 不​​是函数

所以我认为问题就在这里:

$scope.gYap = function(param){ //<-- here gYap is definied as function
    $http.get("php/makine.php?komut=gYap&id="+param).then(function(response) {
     $scope.gYap = response.data;}) //<-- here gYap is redefinied and its no longer function
     $timeout( function(){
        $scope.hepsi();
}, 1000 );

推荐阅读