@Component({
selector: '.donation',
template: `
<figure id="donation" move>
<img src="image/qrcode.png"/>
<figcaption>
Buy me a cup of coffee.
</figcaption>
</figure>
`
})
export class DonationComponent{}
@Directive({
selector: '[move]'
})
export class MoveDirective{}
嘿,我想內MoveDirective和DonationComponent元素的寬度/高度,我閱讀該文檔幾次,但仍然無法找到一種方法,這種answer.Do有人知道這個請幫助我,非常感謝!
非常感謝,它工作完美!但我仍然有點困惑,爲什麼使用offsetHeight而不是高度屬性來獲取元素的高度? –
'ElementRef'已被標記爲安全風險:https://angular.io/docs/js/latest/api/core/index/ElementRef-class.html - 使用它仍然可以嗎? – shiva
@shiva不存在風險,因爲您也從DOM中提取信息,而不是插入危險元素。 – bersling