Новое в Angular 2. Я работаю над компонентом глобальной ошибки, который покажет ошибку сообщений со всех видов/компонентов.Угловые 2 push-сообщения глобальному компоненту
Как я могу общаться глобальный компонент ошибки из другого компонента. **
// appComponent.ts
appComponet will have several components
@Component({
selector: 'app',
template: `
<notification-component></notification-component>
<header-component></header-component>
<router-outlet></router-outlet>
<footer-component></footer-component>
})
**I like to push messages to notification-component.
here is the notificationComponent**
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'notification-component',
templateUrl:"app/notification/notification-view.component.html",
styleUrls:["app/notification/css/notification-view.component.css"]
})
NotificationViewComponent will have notificationMessages
export class NotificationViewComponent implements OnInit {
notificationMessages = [];
hideNotification: boolean = false;
ngOnInit(): void {
this.notificationMessages.push("We arre sorry -- an error occurred while one of your request. ");
}
hideNotificationSection() {
this.hideNotification = true;
}
}
Я пытаюсь нажать сообщения от другого компонента (не из приложения Component).
Как я могу передать сообщения компоненту уведомления из другого компонента?
rmat ваш код и задать конкретный вопрос, который может быть непосредственно адресован. –
Я новичок в этом форуме. я постараюсь улучшить –