【发布时间】:2017-06-13 12:43:08
【问题描述】:
我正在尝试使用 ng2-tag-input 为我的下拉菜单创建自定义模板。我以此为参考:this link。我已经使用 observable 检索了一个对象数组并填充了下拉列表。
这是我的 html 代码(还没有按钮):
<div class="users-container">
<tag-input [ngModel]="[]" [style.width]="100" theme="bootstrap" [onlyFromAutocomplete]="false" addOnBlur="true" addOnEnter="true" addOnSpace="true">
<tag-input-dropdown [showDropdownIfEmpty]="true" [autocompleteObservable]='autocompleteItems$' [identifyBy]="'id'" [displayBy]="'name'">
<!--custom template-->
<ng-template let-item="item" let-index="index">
<div class="float-left">
<img class="user-image" src="{{item.photo}}" alt="user-image">
</div>
<div class="float-right">
<span class="name">{{item.name}}</span>
<span class="name">{{item.lname}}</span>
<p>( {{item.dept}} )</p>
</div>
<div class="clear"></div>
</ng-template>
</tag-input-dropdown>
</tag-input>
我能够成功获取我的自定义模板,但我还需要显示两个按钮以及下拉值,例如:the custom template repeats and at the end, there are these 2 buttons I need。我不知道如何添加它们,因为我是 Angular2 的新手。任何帮助将不胜感激。
【问题讨论】:
标签: html angular ng-template ng2-tag-input