简体   繁体   English

如何动态绑定Angle 2下拉列表

[英]How to bind angular 2 dropdown dynamically

I have a dropdown like shown below 我有一个如下所示的下拉列表

<select  id="usersList" style="width:200px" (change)="onUserChange($event)">
 <option value="" disabled selected>Select a User</option>
 <option *ngFor="let item of users" [value]="item.sid">{{item.lastName +', '+ item.firstName}}</option>
</select>

After selecting any value from the dropdown, I am deleting that value, Afer deletion how can I refresh the drop-down values again. 从下拉列表中选择任何值后,我将删除该值,删除后如何再次刷新下拉列表中的值。

after successful deletion, you should call the same function which is giving you the drop-down output I hope you will get updated data after deletion of your one value. 成功删除后,您应该调用相同的函数,该函数会为您提供下拉输出,希望您删除一个值后会得到更新的数据。

delete() {
        this.us.DeleteUser(user).subscribe((data) => { this.yourfunction_to_call_dropdowndata();
}, (err) => { console.log("Add error", err) });
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM