我目前正在尝试动态删除angular-ui下拉列表中的元素,但是下拉内容似乎“重置”到我想要删除的元素。
这是一个说明问题的探测器,您可以点击“外部移除”或其中一个下拉元素来触发这种现象。
http://plnkr.co/edit/y4myttDQBDUymJYQEfmL?p=preview
用于删除的代码:
$scope.remove = function(index) { $scope.items = $scope.items.splice(index,1); };有谁知道我在这里做错了什么? 谢谢
I'm currently trying to dynamically remove elements from a angular-ui dropdown instance, but the dropdown contents seems to 'reset' to the element I want to remove.
Here's a plunker illustrating the problem, you can either click on 'external remove' or on one of the dropdown elements to trigger the phenomena.
http://plnkr.co/edit/y4myttDQBDUymJYQEfmL?p=preview
Code used to remove:
$scope.remove = function(index) { $scope.items = $scope.items.splice(index,1); };Does anyone have an idea what I'm doing wrong here? Thanks
最满意答案
'splice'函数返回被删除的项。 只是用。
$scope.items.splice(index,1);并且不要将项目设置为返回值。
the 'splice' function returns the item that is removed. Just use.
$scope.items.splice(index,1);And don't set items to the return value.
更多推荐
发布评论