Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: v2.disconnectDevice is not a function (angular)

Tags:

html

angularjs

I have a table with devices and on each row i have option to disconnect device. When i disconnect one device, everything works great, but when i wan't to disconnect second device, i get the following error TypeError: v2.disconnectDevice is not a function

This is my controller

.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);
                });
            }
        }
     }])

And this is my HTML table:

<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>

What am I doing wrong?

like image 922
Valor_ Avatar asked Sep 14 '26 17:09

Valor_


1 Answers

You just need to remove

$scope.disconnectDevice = false;

and

$scope.disconnectDevice = true;
like image 186
DrYuri Avatar answered Sep 16 '26 08:09

DrYuri