繁体   English   中英

Ember.js(如果日期变量超过了当前日期)

[英]Ember.js if date variable has gone over current date

我是ember.js的新手,正在创建一个带有函数的模型。 该模型本身将保存一个日期的数据,但是我正在创建另一个属性作为布尔值,如果模型日期已超过当前日期,则我希望布尔值表示为false。

如果我给你看一个例子,可能会更容易理解:

title: DS.attr('string'),
date: DS.attr('date'),
live: DS.attr('boolean', { defaultValue:function () {
    if (date)
})}

因此,如果日期低于当前日期,我希望Live等于true,但我不确定或是否真的将其放入控制器中,因为必须不断检查此变量

您可以在模型中将live定义为计算属性。

live: Ember.computed('date',function () {
        //this.get('date') - you will get the date for the current record, and you can do any logic and return the corresponding values.
    })
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM