Я пытаюсь связаться с одной из страниц router-oulet
с родительским компонентом как app component
, но не работает.
вот мой код:
home.component.ts:
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
@Component({
templateUrl:"home.component.html"
})
export class HomeComponent implements OnInit {
@Output() myEmiter = new EventEmitter<string>();
ngOnInit(){}
sendMessage(msg){
this.myEmiter.emit(msg);
}
}
В приложении component.ts:
import { Component, Input } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular 6';
@Input() msg:string = "default"; //msg not updating at all
}
Демонстрационная версия