【发布时间】:2018-02-12 18:59:52
【问题描述】:
当我尝试将数据从父组件传递到子组件时出现错误。
这是我在父组件中放置的标签。
<pop-up [showPopUp]="true" [content]="content" [title]="title goes here"></pop-up>
子组件
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'pop-up',
templateUrl: './pop-up.component.html',
styleUrls: ['./pop-up.component.css']
})
export class PopUpComponent implements OnInit {
@Input()
showPopUp: boolean;
@Input()
title: string = "";
@Input()
content: string = "";
constructor() {
}
ngOnInit() {
debugger;
}
proceed() {
this.showPopUp = true;
}
closePopUp() {
this.showPopUp = false;
}
}
我想像这样在HTML中使用变量showPopUp,标题和内容
<h5 class="modal-title" id="exampleModalLabel">{{title}}</h5>
<h5 class="modal-title" id="exampleModalLabel">{{content}}</h5>
我不确定我到底做错了什么。
【问题讨论】:
标签: angular angular-components