@@指令的输出将在父级中打印,但无法更新父级组件中的值

问题描述 投票:0回答:1

parent.component.html

  <div draggable (dragging)="copyDragging($event)">

parent.component.ts

copyDragging(event) {
    console.log('copyDragging :', event); // good
    this.copyBoxDragging = event; // not reflected in html
}

draggable.directive

@Output() dragging = new EventEmitter();
mousedrag$.subscribe(() => {
    if (!this._dragging) {
        this.dragging.emit(true);
        this._dragging = true;
    }
});

问题

请参见parent.component.ts]中的[C0?始终正确打印期望值。但在父组件(下一行)中赋值不会反映在父html

有什么阻止我在父组件中分配发射值吗?

angular angular-directive
1个回答
0
投票

尝试强制更改检测

console.log
© www.soinside.com 2019 - 2024. All rights reserved.