Replace device promise with a scope watcher.

This commit is contained in:
Simo Kinnunen
2014-03-18 20:59:22 +09:00
parent ff6984b7d6
commit fc24cd087c
5 changed files with 174 additions and 142 deletions

View File

@@ -1,17 +1,18 @@
module.exports = function DeviceControlCtrl($scope, $routeParams, $location, DeviceService, GroupService, ControlService) {
$scope.control = null
$scope.device = {
promise: DeviceService.get($routeParams.serial, $scope)
.then(function(device) {
return GroupService.invite(device)
})
.then(function(device) {
$scope.device.value = device
$scope.control = ControlService.forOne(device, device.channel)
return device
})
.catch(function(err) {
$location.path('/')
})
}
$scope.device = null
$scope.control = null
DeviceService.get($routeParams.serial, $scope)
.then(function(device) {
return GroupService.invite(device)
})
.then(function(device) {
$scope.device = device
$scope.control = ControlService.forOne(device, device.channel)
return device
})
.catch(function(err) {
$location.path('/')
})
}