在html中,我有一个简单的文本,我想在发布事件时更改。
JS
this.state = "before";
var zoneA = this;
zoneA.state = "after"; <--- WORKS
zoneA.events.subscribe('done:connect', (userEventData) => {
zoneA.state = "after"; <--- DOES NOT GET TRIGGERED
});
HTML
<div *ngIf="state == 'before'" class="beforePublish">Hello</div>
<div *ngIf="state == 'after'" class="afterPublish">Hello</div>
CSS
.beforePublish
{
color: blue;
}
.afterPublish
{
color: red;
}
当我在zoneA.state = "after"
之外拨打zoneA.events.subscribe(...);
时,它有效。但放在里面并不会引发变化。
有人知道如何解决这个问题吗?