typescript这不能在模块体内引用

时间:2015-04-28 22:40:22

标签: typescript

我有一个类似

的模块
Select FMUM.DimSubscriptionKey, sum(FMUM.TotalUnits) as TotalUnits, sum(FMUM.AI_NormalizedUsage) as AI_NormalizedUsage, sum(FMUM.AI_NormalizedUsage) / sum(FMUM.TotalUnits) NewCalculatedField 
 from [AI_DataMart].[AzureViews].[v_FactMeteredUsageMonthly] as FMUM
join [AI_DataMart].[AzureViews].[v_DimServiceExtended] as SE on(FMUM.DimServiceKey = SE.DimServiceKey)
join [AI_DataMart].[AzureViews].[v_DimAccount] as A on(FMUM.DimAccountKey = A.DimAccountKey)
Join [AI_DataMart].[AzureViews].[v_DimSubscription] as SU on(FMUM.DimSubscriptionKey = SU.DimSubscriptionKey)
where 
 FMUM.DimDateKey >= '20150201'And FMUM.DimDateKey <= '20150331'
And SE.Workload = 'SQLDB'
And SE.ResourceName != 'SQL Reporting Hours'
And (SU.AI_BillingType = 'EA' or SU.AI_BillingType = 'Direct') 
 AND SU.IsFraudIdentified = 0
AND SU.AI_IsTest = 0
AND SU.DimBillingSystemKey = 1
AND FMUM.DimSubscriptionKey = '4707785'
group by FMUM.DimSubscriptionKey

如果我没有模块,它可以工作。但我需要保留模块,我还需要监视器[“trayController”]来访问进程回调中的元素,这样我就不会丢失范围。我该怎么做?

1 个答案:

答案 0 :(得分:0)

根据new animalPositionMonitor(this);,您应该将animalPositionMonitor重构为class,因为您使用new进行调用。

在你的代码中加入你正在向类型流处理程序的me添加内容。要将this传入您将使用lambda,无需在变量this中捕获monitor

class animalPositionMonitor{
    constructor(trayContrller:ITrayController){
        var me: IGenXStreamHandler<IAnimal> = new GenXStreamHandler('Animal');
        me.process = animal => {
            var ll = this["trayController"].gridOptions.data.length**;
        }   
    }
}

此快速视频可帮助您更好地了解thishttps://www.youtube.com/watch?v=tvocUcbCupA