javascript - 从下拉列表中选择多个项目以填充在页面上

标签 javascript jquery html angularjs twitter-bootstrap

我正在不同面板中显示数组中的数据,用户可以选择从 View 中删除面板,并且删除的面板将填充在下拉菜单中。用户可以灵活地选择多个面板标题,以使用所选面板重新填充页面。

目前我可以删除面板 - 将它们推送到新数组并使用从数组中删除的面板标题填充下拉列表。

我正在使用 bootstrap 和 Angular - 此时我无法正确显示下拉菜单,并且不确定出了什么问题......这是我的下拉菜单 html:

<select multiple>
  <option *ngFor="let item of dropdownlist">{{item.title}}</option>
</select>

这只是显示为一个空矩形,当我删除面板时,标题显示在下拉列表中,但似乎缺少样式

This is how my dropdown looks populated

这就是我想要的样子:

Multiple Select boxes: https://silviomoreto.github.io/bootstrap-select/examples/#multiple-select-boxes

这也是我删除面板并将其添加到数组的方式:

<a title="Remove Panel" (click)="removePanel(i);">
   <i class="glyphicon glyphicon-remove"></i>
</a>

removePanel(index: number): void {
    this.dropdownlist.push(new Object(this.items.splice(index, 1)[0]));
    }

dropdownlist: Array<any> = [];

items: Array<Panel> = [
        new Panel(1, 'panel 1', 'show text', 'test data in modal'),
        new Panel(2, 'panel 2','show image', 'more test data'),
        new Panel(3, 'panel 3', 'show graph', 'more and more data')
    ];

我也不确定我的添加函数从下拉菜单到项目的外观如何,并且与我的removePanel函数相反?

最佳答案

这不是您问题的答案,但我建议您使用select2

关于javascript - 从下拉列表中选择多个项目以填充在页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42994356/

相关文章:

javascript - 如何让滚动窗口影响滚动的div内容?

javascript - Javascript 中破坏性与非破坏性方法的命名约定

javascript - 如何通过类名和过滤函数获取attr值

php - 如果除了 url 之外什么都没有创建网站的屏幕截图图像?

javascript - 使用javascript在div中创建多个span

Javascript 未检测滚动方向

html - 调整菜单和文本的大小

javascript - 如何使 html 和 javascript 代码同时可重用?

javascript - 将路径数组转换为数据结构

javascript - 使用 Jquery/Javascript 根据下拉选项删除元素