我有一个组件,如:

App.TestCompComponent = Ember.Component.extend({
    title: 'Test Component',

    disablePastChanged: function(){
        alert('disable past changed');
    }.observes('disablePast').on('init'),

    prop1Changed: function(){
        alert('Prop1 changed');
    }.observes('prop1').on('init')
});

和把手模板如下:

{{#test-comp disablePast=disablePast prop1=prop1}}
{{/test-comp}}

现在当从父组件设置此组件的任何属性/ attrs时,如this.set('disablePast',false),两个观察者都被触发(基本上所有的attrs观察者都被触发) . 这是正确的行为吗?到目前为止,我担心它应该只解雇改变的 property /阁楼 .

JS Bin here - 为什么它在启动时触发观察者,那些属性没有被设置在任何地方?当您单击按钮并且它仅设置一个属性/ attrs时,它会为属性激发观察者两次 .

我在这做错了什么?

Update:

或者我们应该为组件使用新的生命周期钩子:

didInitAttrs
didReceiveAttrs
willRender

但是有了这些钩子,我不知道哪个属性实际发生了变化 . 它为我提供了更新的属性 .

谢谢!

如果有人正在寻找 solutionhttp://discuss.emberjs.com/t/ember-1-13-attrs-call-property-change-on-all-observers/8212