TypeError:v2.disconnectDevice不是函数(angular)

时间:2015-11-11 08:35:42

标签: html angularjs

我有一个带有设备的表,每行我都可以选择断开设备。 当我断开一台设备时,一切都很好,但是当我不想断开第二台设备时,我收到以下错误TypeError: v2.disconnectDevice is not a function

这是我的控制器

.controller('subscriber', ['$scope', '$routeParams', 'userEndPointService', function($scope, $routeParams, userEndPointService){
        //Disconnect device
        $scope.disconnectDevice = false;
        $scope.disconnectDevice = function(deviceUid, $index){
            var c = confirm("U sure?");
            if (c == true) {
                userEndPointService.method("disconnectDevice", {"deviceUid" : deviceUid}).then(function(){
                    $scope.disconnectDevice = true;
                    $scope.subDevice.splice($index, 1);
                });
            }
        }
     }])

这是我的HTML表格:

<table class="table table-bordered table-hover dataTable" >
  <thead>
  <tr role="row">
  <th class="sorting_asc" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">Device type</th>
  <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">Device UID</th>
  <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending">Device provisioning date</th>
  <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">Video type</th>
  <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Postal code: activate to sort column ascending">Region</th>
  <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Post: activate to sort column ascending">Disconect</th>
  </tr>
  </thead>
  <tbody>
  <tr role="row" class="odd" ng-repeat="row in subDevice track by $index">
  <td>{{row.deviceTypeDesc}}</td>
  <td>{{row.deviceUid}}</td>
  <td>{{row.deviceProvisioningDate}}</td>
  <td>{{row.videoTypeDesc}}</td>
  <td>{{row.regionName}}</td>
  <td><button class="btn btn-block btn-info btn-flat" ng-click="disconnectDevice(row.deviceUid, $index)">Disconnect</button></td>
  </tr>
  </tbody>
  </table>

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您只需要删除

$scope.disconnectDevice = false;

$scope.disconnectDevice = true;