Angularjs Angular JS获取所选项目值li html
我有一个角度列表,希望得到它的选定值,但它只对点击事件起作用Angularjs Angular JS获取所选项目值li html,angularjs,Angularjs,我有一个角度列表,希望得到它的选定值,但它只对点击事件起作用 <div ng-hide="hideCustomerDropdown" id="customer-dropdown" class="slidedown-menu"> <div class="slidedown-header"> </div> <div class="slidedown-body"
<div ng-hide="hideCustomerDropdown" id="customer-dropdown" class="slidedown-menu">
<div class="slidedown-header">
</div>
<div class="slidedown-body">
<ul class="customer-list list-unstyled">
<li ng-repeat="customers in customerArray" >
<span class="fa fa-fw fa-user"></span>{{ customers.customer_name }} ({{ customers.customer_mobile || customers.customer_email }})
</li>
</ul>
</div>
</div>
不确定是否理解您的问题,但尝试通过添加 $scope.$apply
在then函数的末尾。您这样说是什么意思:获取id的选定值。它在单击事件中唯一起作用?你能解释一下你是如何选择商品的吗?单击“将所选项目保存到某个变量中”或“设置项目的某些属性”。@BillP请参阅“编辑”
$("#customer-name").on("click", function() {
$scope.showCustomerList(true);
});
$scope.showCustomerList = function (isClick) {
$http({
url: API_URL ,
method: "GET",
cache: false,
processData: false,
contentType: false,
dataType: "json"
}).
then(function(response) {
$scope.hideCustomerDropdown = false;
$scope.customerArray = [];
window.angular.forEach(response.data, function(customerItem, key) {
if (customerItem) {
$scope.customerArray.push(customerItem);
}
});
}, function(response) {
window.toastr.error(response.data.errorMsg, "Warning!");
});
};