———————
app = angular.module('angularWebApp.indexController', []);
app.controller('indexController', function($scope, $http, $rootScope, $sce, $timeout, $modal) {
$scope.controllsubmit = function() {
//console.log("I was called!");
};
if ($scope.user !== undefined) {
if ($scope.user.software_key.constructor === Array) {
//angular.forEach($scope.user.software_key, function(software_key, key) {
//$scope.theKeys = $scope.user.software_key;
if($scope.user.software_key.length > 1)
{
var keySelectInstance = $modal.open({
templateUrl: '../view/multikeyModal.html',
controller: 'multikeyModalController',
backdrop: 'static'
});
var software_key = '';
keySelectInstance.result.then(function (result) {
//console.log('result: ' + result);
$rootScope.software_key = software_key = result;
//alert($scope.software_key);
$http.get('http://54.213.13.56/api/' + software_key + '/remotes').
success(function(data) {
if (data.id === 'error') {
console.log(data);
} else {
$scope.machineList = data;
//$rootScope.key = software_key;
//console.log($scope.user.software_key[1]);
//console.log($scope.key);
$scope.testing = 'http://54.213.13.56/settings';
$scope.testingUrl = $sce.trustAsResourceUrl($scope.testing);
//Wait until the current $digest is done and then run the form submit to update the iframe
$timeout(function() {
//console.log('I made it');
var frm = angular.element('#myForm');
frm.submit();
});
}
}).
error(function(data) {
alert(data);
});
},
function() {
//console.info('Modal dismissed at: ' + new Date());
});
} else {
$rootScope.software_key = $scope.user.software_key[0];
alert($scope.user.software_key[0]);
//alert($scope.software_key);
$http.get('http://54.213.13.56/api/' + $scope.user.software_key[0] + '/remotes').
success(function(data) {
if (data.id === 'error') {
console.log(data);
} else {
$scope.machineList = data;
//$rootScope.key = software_key;
//console.log($scope.user.software_key[1]);
//console.log($scope.key);
$scope.testing = 'http://54.213.13.56/settings';
$scope.testingUrl = $sce.trustAsResourceUrl($scope.testing);
//Wait until the current $digest is done and then run the form submit to update the iframe
$timeout(function() {
//console.log('I made it');
var frm = angular.element('#myForm');
frm.submit();
});
}
}).
error(function(data) {
alert(data);
});
}
}
}
});