当新属性添加到Ember对象时触发观察者

时间:2016-02-26 12:11:24

标签: ember.js coffeescript

我想触发一个观察者,当另一个Ember对象有一个新的属性集时,该观察者会为一个属性设置一个值。到目前为止,这就是我得到它的方式:

  relationTotalCountObserver: Ember.observer('item.relationships.attachments', ->
  totalCount = @get 'item.relationships.attachments.totalCount'
  if totalCount isnt undefined
    @set 'relationTotalCount', totalCount
  ).on 'init'

该项目之前没有任何 totalCount 属性,最终将使用合并补丁添加它,我需要以某种方式检测到该添加。

0 个答案:

没有答案
相关问题