【发布时间】:2018-11-12 21:16:52
【问题描述】:
下面是我的父组件代码。我正在尝试从中获取数据 自定义绑定组件到应用组件。但我无法得到 来自父组件的值。我的父组件是 customebinding 和子组件是 appcomponent。
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-customebinding',
templateUrl: './customebinding.component.html',
styleUrls: ['./customebinding.component.scss']
})
export class CustomebindingComponent implements OnInit {
name="ramu";
constructor() { }
ngOnInit() {
}
}
html code is
<app-root [recieveName]="name"></app-root>
下面是我的子组件。
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
@Input() recieveName:string;
}
html code is
recieve name is {{ recieveName }}
谁能告诉我哪里出错了。
【问题讨论】:
-
控制台有错误吗?
-
控制台没有出现任何错误
标签: angular