【发布时间】:2018-10-11 14:47:08
【问题描述】:
我有两个组件, 1. 应用组件 2.主要组成部分
app.component.ts
ngOnInit () {
this.httpService.get('./assets/batch_json_data.json').subscribe(data => {
this.batchJson = data as string [];
}
我能够将 JSON 从文件中获取到“batchJson”中,并且需要将其传递给我的主要组件以进行进一步操作。
没有任何事件或任何东西可以触发这个。
我还没有实现任何东西,我正在尝试阅读@Input、@Output 等,但不明白它是如何工作的,需要进一步了解。
我刚刚在 main.component.ts 中声明了基础
import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { AppComponent } from '../app.component';
export class MainComponent implements OnInit {
}
请帮帮我,我是 Angular 的绝对菜鸟,无法尝试任何事情,因为我的概念不清楚,我确实浏览过 Stack Overflow,答案不符合我的要求。
【问题讨论】:
标签: json angular components angular6