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?
You just need to remove
$scope.disconnectDevice = false;
and
$scope.disconnectDevice = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With