【发布时间】:2014-07-25 16:32:06
【问题描述】:
我正在尝试使用 Ember CLI 干燥我的应用程序并将一些功能移动到宏中。在阅读this article 之后,我认为我可以让事情正常工作,但是在尝试使用带有任何参数的宏时,我得到了undefined is not a function TypeError: undefined is not a function 错误。如果我不传递任何参数,则 ember 不会引发错误。要生成文件,我使用命令ember generate util calc-array
// utils/calc-array.js
import Ember from 'ember';
export default function calcArray(collection, key, calculation) {
return function() {
...
}.property('collection.@each');
}
// controller/measurements.js
import Ember from 'ember';
import calculate from '../../utils/calc-array';
export default Ember.ArrayController.extend({
high: calculate(this.get('model'), 'value', 'high'),
...
});
【问题讨论】: