试图在动态表中插入下拉列表,但我不知道该怎么做。我想在最后一列中插入带有一些值的下拉列表。请帮助任何人找到解决方案。
head = [ "Name", "Age", "Gender","Action"];
details = [
{ "name": "star1", "age": "25", "gender": "male","action": "" },
{ "name": "star2", "age": "22", "gender": "female","action": "" },
{ "name": "star3", "age": "21", "gender": "male","action": "" },
{ "name": "star4", "age": "35", "gender": "female","action": "" },
];
constructor(){
this.tableHead = this.head;
this.userDetails = this.details;
}
演示:https://stackblitz.com/edit/angular-bfs3gp?file=src/app/app.component.ts
答案 0 :(得分:0)
我为您提供了解决方案。您能否将您的详细信息数组替换为
<h1 class = "Heading">IRON MAN</h1>
<h1 class = "Heading">CAPTAIN AMAERICA</h1>
<h1 class = "Heading">THOR</h1>
<h1 class = "Heading">BLACK WIDOW</h1>
然后将 dynamic-table.component.html 替换为以下代码
details = [
{ name: "star1", age: "25", gender: "male", action: ["Edit", "Delete"] },
{ name: "star2", age: "22", gender: "female", action: ["Edit", "Delete"] },
{ name: "star3", age: "21", gender: "male", action: ["Edit", "Delete"] },
{ name: "star4", age: "35", gender: "female", action: ["Edit", "Delete"] }
];
现在,我希望您的担忧得到解决。 希望这可以帮助! 谢谢。