@Output
должны использоваться с отношениями родитель-ребенок, вы можете использовать Общий сервис - лучший вариант для вашей ситуации:
Создать один сервис (Shared.Service.ts ):
import { Injectable } from '@angular/core';
import {Subject} from 'rxjs';
@Injectable()
export class SharedService {
change = new Subject<number>();
constructor() { }
emitValue(value: number){
this.change.next(value);
}
}
Контроллер нижнего листа:
@Component({
selector: "bottom-sheet-overview-example-sheet",
templateUrl: "bottom-sheet-overview-example-sheet.html"
})
export class BottomSheetOverviewExampleSheet {
constructor(
private _bottomSheetRef: MatBottomSheetRef<BottomSheetOverviewExampleSheet>,
private service: SharedService
) { }
manipulate() {
console.log("DIV CLICKED");
this.service.emitValue(99);
}
}
App.component.ts:
import { Component, Output, EventEmitter } from "@angular/core";
import {
MatBottomSheet,
MatBottomSheetRef
} from "@angular/material/bottom-sheet";
import { Subject } from "rxjs";
import { SharedService } from "./shared.service";
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
myCount: number = 0;
constructor(
private _bottomSheet: MatBottomSheet,
private sharedService: SharedService
) {
this.sharedService.change.subscribe(value => {
if (value) {
console.log(value);
this.myCount = value;
}
});
}
openBottomSheet(): void {
this._bottomSheet.open(BottomSheetOverviewExampleSheet);
}
}
Here
является рабочим демо:)