Angularjs 设置自定义属性

Angularjs 设置自定义属性,angularjs,Angularjs,在我的AngularJS应用程序中,我的控制器设置客户信息如下: $scope.customers = [{'name': 'John', 'customerID': '1'}, {'name': 'Mike', 'customerID': '2'}]; <div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div> 如何在自定义属性cid中存储客户ID <div ng-re

在我的AngularJS应用程序中,我的控制器设置客户信息如下:

$scope.customers = [{'name': 'John', 'customerID': '1'}, {'name': 'Mike', 'customerID': '2'}];
<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>
如何在自定义属性cid中存储客户ID

<div ng-repeat="customer in customers" cid=""></div>

像这样

<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>

您需要执行以下操作:

$scope.customers = [{'name': 'John', 'customerID': '1'}, {'name': 'Mike', 'customerID': '2'}];
<div ng-repeat="customer in customers" cid="{{customer.customerID}}"></div>

但有效的html方法是在cid之前添加“数据”:

<div ng-repeat="customer in customers" data-cid="{{customer.customerID}}"></div>


抱歉,但您显然需要手柄:cid=“{customer.customerID}}”我通常使用它来压缩特殊属性(如ng src),或者在HTML标记之外显示$scope,如果没有手柄,则无法工作:cid=“{customer.customerID}”抱歉打扰您,但如果您喜欢数据cid=,您所要求的内容在我看来毫无意义{{customer.customerID}“所有用户的值都发生了变化,最后得到的是最后一个用户id的值^^