diff --git a/awx/ui/client/src/job-templates/labels/labelsList.directive.js b/awx/ui/client/src/job-templates/labels/labelsList.directive.js index bb1a825273..a5f055bb6e 100644 --- a/awx/ui/client/src/job-templates/labels/labelsList.directive.js +++ b/awx/ui/client/src/job-templates/labels/labelsList.directive.js @@ -74,13 +74,17 @@ export default }); }; - scope.$watch(scope.$parent.list.iterator+".summary_fields.labels.results", function() { + scope.$watchCollection(scope.$parent.list.iterator, function() { // To keep the array of labels fresh, we need to set up a watcher - otherwise, the // array will get set initially and then never be updated as labels are removed if (scope[scope.$parent.list.iterator].summary_fields.labels){ scope.labels = scope[scope.$parent.list.iterator].summary_fields.labels.results; scope.count = scope[scope.$parent.list.iterator].summary_fields.labels.count; } + else{ + scope.labels = null; + scope.count = null; + } }); } };