From aa961efd0634b3a0af48c3cd3a5f630de9e4670a Mon Sep 17 00:00:00 2001 From: Chaoyi Zha Date: Sat, 6 May 2017 12:45:58 -0400 Subject: [PATCH] Use angular bindings for toggleAPIStatus --- public/directives/editUserApiInfoModal.html | 6 ++---- public/js/AdminCtrl.js | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/public/directives/editUserApiInfoModal.html b/public/directives/editUserApiInfoModal.html index d46029e..fe16db4 100644 --- a/public/directives/editUserApiInfoModal.html +++ b/public/directives/editUserApiInfoModal.html @@ -11,11 +11,9 @@

API Active: - - {{apiActive}} - + - toggle + toggle

diff --git a/public/js/AdminCtrl.js b/public/js/AdminCtrl.js index bd0a2af..586fb96 100644 --- a/public/js/AdminCtrl.js +++ b/public/js/AdminCtrl.js @@ -57,15 +57,12 @@ polr.directive('editUserApiInfoModal', function () { } // Toggle API access status - $scope.toggleAPIStatus = function($event) { - var el = $($event.target); - var status_display_elem = el.prevAll('.status-display'); - + $scope.toggleAPIStatus = function() { apiCall('admin/toggle_api_active', { 'user_id': $scope.userId, }, function(new_status) { - new_status = res_value_to_text(new_status); - status_display_elem.text(new_status); + $scope.apiActive = res_value_to_text(new_status); + $scope.$digest(); }); };