【发布时间】:2018-04-06 18:20:56
【问题描述】:
当我单击按钮时,我将“copyRow”元素发送到“copyItem”方法。我正在使用“Typescript”文件中的“item”变量来均衡“copyItem”元素。
当我想显示“[object htmldivelement]”作为输出时,这个“html 文件中的项目”变量。
create.component.html
<div class="questions">
<div class="form-group copy-row" #copyRow>
<label>Question</label>
<input type="text" class="form-control" placeholder="Question title">
</div>
{{ item }}
</div>
<button type="button" class="btn btn-primary" (click)="copyItem(copyRow)">Add</button>
create.component.ts
item;
constructor() { }
ngOnInit() {
}
copyItem(row) {
this.item = row;
}
编辑
我的目标是做一个调查项目。 当我单击“添加”按钮时,相同的“#copyRow”元素将显示在 {{ item }} 部分。但是,我得到了类似于第二个链接的输出。
【问题讨论】:
-
你想达到什么目的?
-
'[object htmldivelement]' 我希望出现纯 html 输出而不是这个输出。
-
this.item = row.innerHTML; -
我的目标是做一个调查项目。当我单击“添加”按钮时,相同的“#copyRow”元素将显示在 {{ item }} 部分。但是,我得到了像第二个链接这样的输出。 1:prntscr.com/j1ncp1 2:prntscr.com/j1nd19
标签: html angular typescript angular5