diff --git a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts index 50a4f630e50..92bff6b1e89 100644 --- a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts +++ b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts @@ -32,7 +32,11 @@ export class StackdriverAggregationCtrl { this.alignOptions = options.alignOptions; this.setAggOptions(); this.setAlignOptions(); - $scope.$on('metricTypeChanged', this.setAlignOptions.bind(this)); + const self = this; + $scope.$on('metricTypeChanged', () => { + self.setAggOptions(); + self.setAlignOptions(); + }); } setAlignOptions() { diff --git a/public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts b/public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts index b017f722b2c..dc3bd853463 100644 --- a/public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts +++ b/public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts @@ -41,7 +41,7 @@ export class StackdriverFilterCtrl { datasource: any; /** @ngInject */ - constructor(private $scope, private uiSegmentSrv, private templateSrv) { + constructor(private $scope, private uiSegmentSrv, private templateSrv, private $rootScope) { this.datasource = $scope.datasource; this.target = $scope.target; this.metricType = $scope.defaultDropdownValue; @@ -180,7 +180,7 @@ export class StackdriverFilterCtrl { this.target.unit = unit; this.target.valueType = valueType; this.target.metricKind = metricKind; - this.$scope.$broadcast('metricTypeChanged'); + this.$rootScope.$broadcast('metricTypeChanged'); } async getGroupBys(segment, index, removeText?: string, removeUsed = true) { diff --git a/public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts b/public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts index d4f295053ec..aa830e7bded 100644 --- a/public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts +++ b/public/app/plugins/datasource/stackdriver/specs/query_filter_ctrl.test.ts @@ -420,7 +420,7 @@ function createCtrlWithFakes(existingFilters?: string[]) { refresh: () => {}, }; - return new StackdriverFilterCtrl(scope, fakeSegmentServer, new TemplateSrvStub()); + return new StackdriverFilterCtrl(scope, fakeSegmentServer, new TemplateSrvStub(), { $broadcast: param => {} }); } function createTarget(existingFilters?: string[]) {