Javascript 从Coffeescript中的指令调用服务中的方法时出错

Javascript 从Coffeescript中的指令调用服务中的方法时出错,javascript,angularjs,service,coffeescript,directive,Javascript,Angularjs,Service,Coffeescript,Directive,我有一个名为Dashboard LayoutStyleCalculatorService的服务,使用以下方法。其他方法被删除,因为它们与问题无关: styleFns = table: @computeStyleForTable single_value: @computeStyleForSingleValue @computeStyleFor = (type, height = null) -> return styleFns[type](height)

我有一个名为
Dashboard LayoutStyleCalculatorService
的服务,使用以下方法。其他方法被删除,因为它们与问题无关:

  styleFns =
    table: @computeStyleForTable
    single_value: @computeStyleForSingleValue

  @computeStyleFor = (type, height = null) ->
    return styleFns[type](height)
通过两个不同的指令调用此服务:

指令1:

scope.computeStyle = (component) ->
  if component?.height?
    height = component.height * 50
  return DashboardLayoutStyleCalculator.computeStyleFor(component.element.type, height)
指令2:

scope.computeStyle = (element, rowComponent) ->
  return DashboardLayoutStyleCalculator.computeStyleFor(element.type, rowComponent?.height?)
我的代码在nut shell中的作用是,根据
computeStyleFor
中的输入类型,它为表或单个值可视化调用两种不同的方法。还有一些基于某些参数的动态高度计算,这些参数对于这个问题不是完全必要的

在浏览器中运行此代码时,出现以下错误:

main.webpack-a9f3967e.js:27 TypeError: e[t] is not a function
    at Object.computeStyleFor (https://localhost:54321/webpack/main.webpack-a9f3967e.js:10:17938)
    at e.t.computeStyle (https://localhost:54321/webpack/main.webpack-a9f3967e.js:10:16879)
    at fn (eval at compile (https://localhost:54321/webpack/vendor.webpack-6f544239.js:49:29700), <anonymous>:4:627)
    at d.$digest (https://localhost:54321/webpack/vendor.webpack-6f544239.js:48:11027)
    at d.$apply (https://localhost:54321/webpack/vendor.webpack-6f544239.js:48:12692)
    at https://localhost:54321/webpack/vendor.webpack-6f544239.js:47:23881 undefined
main.webpack-a9f3967e.js:27类型错误:e[t]不是函数
在Object.computeStyleFor(https://localhost:54321/webpack/main.webpack-a9f3967e.js:10:17938)
在e.t.computeStyle(https://localhost:54321/webpack/main.webpack-a9f3967e.js:10:16879)
fn时(编译时评估)(https://localhost:54321/webpack/vendor.webpack-6f544239.js:49:29700),:4:627)
d.$digest(https://localhost:54321/webpack/vendor.webpack-6f544239.js:48:11027)
d.$适用(https://localhost:54321/webpack/vendor.webpack-6f544239.js:48:12692)
在https://localhost:54321/webpack/vendor.webpack-6f544239.js:47:23881未定义

看来
computeStyleFor
styleFns

都有问题,从我看到的情况来看,我假设调用
component.element.type
会生成一个未过期的键

scope.computeStyle = (component) ->
    if component?.height?
        height = component.height * 50
    return DashboardLayoutStyleCalculator.computeStyleFor(component.element.type, height)
                                                          ^^^^^^^^^^^^^^^^^^^^^^
                                                                |
                                                                ---- Not what you expect
因此,请稍后致电

 @computeStyleFor = (type, height = null) ->
    return styleFns[type](height)
                   ^^^^^^
                      |
                      --- fails as styleFns[type] yields undefined which is not a function
添加一些输出以查看表达式
type
styleFns[type]
yield是什么