Мне нужно отправить JSON от родителя к потомку при нажатии кнопки в parent.component.html с помощью Input Decorator.
Когда я нажимаю кнопку в родительском компоненте, объект JSON доступенв родительском компоненте должен быть отправлен дочернему компоненту.
Мне не нужно использовать сервис здесь.Но как мне сделать это здесь с Input decorator
Я могу отправлять данные о событии щелчка, когда отправляю их от потомка к родителю, но как мне это сделать?
Мой parent.component.ts
import { Component, OnInit ,Input , EventEmitter ,Output} from '@angular/core';
@Component({
selector: 'app-sidenav',
templateUrl: './sidenav.component.html',
styleUrls: ['./sidenav.component.css']
})
export class SidenavComponent implements OnInit {
data=[
{
"name":"pranesh",
"number":"21"
},
{
"name":"pranesh",
"number":"21"
},
{
"name":"pranesh",
"number":"21"
},
{
"name":"pranesh",
"number":"21"
},
{
"name":"pranesh",
"number":"21"
}
]
private details: object;
sendMessage(){
this.details=this.data;
}
constructor() { }
ngOnInit() {
}
}
Мой child.component.ts
import { Component, OnInit ,Input} from '@angular/core';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import {Color, Label } from 'ng2-charts';
@Component({
selector: 'app-content',
templateUrl: './content.component.html',
styleUrls: ['./content.component.css']
})
export class ContentComponent implements OnInit {
@Input() details: object;
constructor() { }
ngOnInit() {
}
}
Я не знаю, как отправить его на щелчок по событию, используя декоратор входных событий, как мне это сделать?