您好我想知道是否有任何方式可以发送有关该详细信息已关闭或打开的信息我的意思是:
<details (click)="changeWrap($event)">
我无法在$ event中看到有关详细信息的任何信息。
我工作角2.谢谢:))
答案 0 :(得分:1)
我编写了一个简单的组件,使用 @ViewChild ,我们可以从模板中获取元素。
然后我们可以访问其中的打开属性。当用户单击details元素时。
import { Component, ViewChild } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<details (click)='detailsClicked()' #detailsElement>
<summary>Copyright 1999-2014.</summary>
<p> - by Refsnes Data. All Rights Reserved.</p>
<p>All content and graphics on this web site are the property of the company Refsnes Data.</p>
</details>
`
})
export class AppComponent {
title = 'Tour of Heroes';
@ViewChild('detailsElement') detailsElement;
detailsClicked() {
setTimeout(() => {
console.log(this.detailsElement.nativeElement.open)
}, 0);
}
}
我使用setTimeout()方法来获取detail元素的最终状态。