我创建了两个全局变量,例如var DiscountRef={};var shareDetail=[];
当用户添加表单时,我将所有值存储在DiscountRef变量中,例如
RefValue = {Mobile:9876543210,Quantity:3}
$scope.shareDetail = Object.Keys(RefValue);//I try Object.entries also
当我想在表中显示数据时
{{shareDetail}}
<div ng-repeat="share in shareDetail">
{{share.Mobile}}
{{share.Quantity}}
</div>
其显示空数组
我也试过这个
<div ng-repeat="(key, value) in shareDetail">
{{key}} : {{value}}
</div>
如何访问特定的键值对,如MobileNo:9876543210&; 数量:3
RefValue = {Mobile:9876543210,Quantity:3}
shareDetail = [];
Object.keys(RefValue).forEach(function(key)
{
shareDetail.push(RefValue[key]);
});
然后您可以执行NG-重复:
<div ng-repeat="(key, value) in shareDetail">
{{key}} : {{value}}
</div>
谢谢