【发布时间】:2018-12-14 19:08:13
【问题描述】:
我在一个组件 (child.html) 中有一个 div,我会触发另一个 (parent.html) 的单击事件,以将布尔值从 false 变为 true。我知道可以将 html 用作<child-component [Event]></child-component>,但孩子必须对用户不可见。
是否可以从 app.css 添加 CSS 以使其不可见? 我不确定是否可以在 Angular 中实现,这是我尝试过的:
child.html:
<div class="notif-filter" (click)="hideNotif(event)"> </div>
child.ts:
public hideNotif(event) {
console.log(event, 'hideNotif is fired !!');
this.hideMe = true;
// this.feedIsVisible = false;
}
parent.html:(这个应该是不可见的)
<child-component></child-component>
父.css:
app-child: { display: none }
父.ts:
@input event: Event (comming from the child)
lockScreen(): void {
this.screenLocked = true;
this.feedIsVisible = false; ==> *This should turn to true depending on
the click event in the child.html*
this.nav.setRoot('ConnexionPage').then();
}
【问题讨论】:
-
组件通信是 Angular 中非常基本的东西,可以很容易地用谷歌搜索。尽管如此:stackblitz.com/edit/…
-
@Carsten 我知道这是一个非常基本的,但通常你必须在 html 文件中纠正一些语法来检索绑定属性,但对我来说,我正在尝试不使用 html,例如
()或 @987654329 @ -
这不是一种角度的方法,因此它是不好的做法。你的理由是什么?
标签: angular typescript events ionic3 dom-events