angular2 getters打破了MDL组件

时间:2017-05-12 16:44:10

标签: angular getter-setter material-design-lite

所以,首先我使用Material Design Lite,以防万一与我的奇怪问题有关。

我有一个包含列表组件的页面

<my-list [list]="list"></my-list>

现在该列表内部包含另一个组件(MDL开关:https://getmdl.io/components/index.html#toggles-section/switch

<my-toggle [toggle]="toggle"></my-toggle>

这是页面提供给列表的数据

list: MyList = {
    items: [{
        id: 'example-id',
        primaryContent: {
            title: 'Example Title',
        },
        secondaryContent: {
            toggle: {
                id: 'example-toggle-id',
                checked: this.dynamicVarExample,
                type: 'switch'
            }
        }
    }]
}

但是当我将其更改为getter(因此数据刷新并且my-list显示最新的dynamicVarExample)时,我的开关停止工作。

get list(): MyList{
    return {
        items: [{
            id: 'example-id',
            primaryContent: {
                title: 'Example Title',
            },
            secondaryContent: {
                toggle: {
                    id: 'example-toggle-id',
                    checked: this.dynamicVarExample,
                    type: 'switch'
                }
            }

        }]
    }
}

有谁知道为什么会这样?好像吸气者会对事件做些什么。

0 个答案:

没有答案
相关问题