输入装饰器未显示来自父组件的数据

时间:2019-05-09 23:20:30

标签: angular typescript

我正在尝试显示从父组件到子组件的数据。我的父组件是TableOverviewComponent,子组件是TableComponent。代码如下。我没有收到任何错误,但是现在正在显示从父组件到子组件的消息

表.component.ts

import { Component, OnInit } from '@angular/core';
import Tabulator from 'tabulator-tables';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-table',
  templateUrl: './table.component.html',
  styleUrls: ['./table.component.css']
})
export class TableComponent implements OnInit {

  constructor(private route: ActivatedRoute) { }
  public message: string = "hello world"
  ngOnInit() {

  }

}

table.component.html

<app-table-overview
  [message]= "message" 
></app-table-overview>

table-overview.component.ts

import { Component, OnInit, Input } from '@angular/core';
import * as c3 from 'c3';
@Component({
  selector: 'app-table-overview',
  templateUrl: './table-overview.component.html',
  styleUrls: ['./table-overview.component.css']
})
export class TableOverviewComponent implements OnInit {
  @Input() message: string
  constructor() { }

  ngOnInit() {
  }
}

table-overview.component.html

<div>
  <h3>Child</h3>
  say {{message}}
</div>

0 个答案:

没有答案