【发布时间】:2015-09-28 10:12:27
【问题描述】:
类似于Angular2 two-way data binding,我有一个父组件和一个子组件。在父组件中,我更改了通过属性传递给子组件的值。孩子的属性名为percentage。
https://gist.github.com/ideadapt/59c96d01bacbf3222096
我想将属性值绑定到 html 属性值。喜欢:
。我没有找到任何有效的语法。所以我最终使用了一个更改监听器来进行一些手动 DOM 更新:
this.progressElement = DOM.querySelector(element.nativeElement, '.progress');
DOM.setAttribute(this.progressElement, "style", `width: ${this.percentage}%`);
有没有更优雅的方法来实现这一点?
【问题讨论】:
标签: data-binding attributes angular