刚开始学习angular2,网上查到的资料很少,自己又遇到了动态增加表格的问题,在此记录一下自己遇到的坑。
页面中的table代码:
<
table
id=
"tableParam"
class=
"tableParam"
>
<
tr
class=
"table-title"
>
<
th
style=
"width: 6%"
>序号
</
th
>
<
th
style=
"width: 25%"
>参数名称
</
th
>
<
th
style=
"width: 18%"
>参数类型
</
th
>
<
th
style=
"width: 11%"
>是否必填
</
th
>
<
th
style=
"width: 30%"
>描述
</
th
>
<
th
style=
"width: 10%"
>操作
</
th
>
</
tr
>
</
table
>
<
div
class=
"add"
>
<
div
class=
"btn"
style=
"padding: 3px;"
>
<
i
class=
"glyphicon glyphicon-plus"
></
i
>
<
a (
click)=
"add()"
style=
"color: #FFF;"
>增加一条
</
a
>
</
div
>
</
div
>
在对应页面的组件component里面加上:
add():
void {
var
trid =
new
Date().
getTime();
this.
paramsNameid =
trid +
'paramsNameid';
this.
paramsDesid =
trid +
'paramsDesid';
this.
paraTypeid =
trid +
'paraTypeid';
this.
checkBoxid =
trid +
'checkBoxid';
var
objtr =
document.
createElement(