gpt4 book ai didi

javascript - HTML 按钮和 Controller 未连接

转载 作者:行者123 更新时间:2023-12-03 06:07:52 25 4
gpt4 key购买 nike

尝试通过 ng-click 删除列表,但 html 和 Controller 似乎无法通信。

<div class="list-group">
<span ng-repeat="list in vm.lists"
class="list-group-item">
<a class="btn btn-primary pull-right" ng-click="vm.elim(list)">
<i class="glyphicon glyphicon-trash"></i>
</a>
<a class="btn btn-primary pull-right" ui-sref=
"lists.view({ listId:list._id })">
<i class="glyphicon glyphicon-edit"></i>
</a>
<h4 class="list-group-item-heading" ng-bind="list.name"></h4>
</span>
</div>

function elim(list) {
alert("works");
if ($window.confirm('Are you sure you want to delete?')) {
vm.list.$remove($state.go('lists.list'));
}
}

单击图标时至少应该有一个警报,但什么也没有发生。有建议吗?

最佳答案

就像 Esteban 所说,你的 elem 函数应该是作用域变量的一部分,例如

$scope.vm.elem = function(){};

关于javascript - HTML 按钮和 Controller 未连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39454573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com