gpt4 book ai didi

javascript - 具有多个数组的数组上的 ng-repeat

转载 作者:行者123 更新时间:2023-12-02 13:44:44 25 4
gpt4 key购买 nike

这是我的 angularjs 函数

$scope.getSpecificCat = function(p_cat) {
$http.get(url+'getSpecificCatJson/' + p_cat).success(function(data){
$scope.specifics = data;
}).error(function(){
//alert('there is some errror while fetching product ');
});
}

具体内容包含两个数组,例如[Array[2],Array[2]]。现在我的问题是如何在 ng-repeat 中显示这些数组值。我想详细说明我的问题第一个数组包含类似 0:object 的数据,而 object 具有 Product_name:"tv"而第二个数组有 0:"30"这是我的模态 公共(public)函数 get_specific_cat($p_cat)

{                 
$current_date = date('d-M-Y');
$current_new = strtotime($current_date);
$this->db->select("*, ((p_bid/total_bid)*100) as progress");
// print_r($current_new);die;
$this->db->where('p_cat',$p_cat);
$this->db->where('p_status','active');
$query = $this->db->get('product');
$data = $query->result();
$percent_array =[];

foreach ($data as $row) {
$id = $row->p_id;
$ppr = $row->pp_date;
$pcr = $row->pc_date;
$ppn = strtotime($ppr);
$pcn = strtotime($pcr);
$p_name = $row->p_name;
if($row->p_cat == 'diamond')
{
return $data;
}
else if($row->p_cat == 'gold' && $ppr < 1)
{
return $data ;
}
else if(!empty($pcn && $ppn) && $pcn != $ppn)
{
$percent_array[] = (($current_new-$ppn) * 100)/($pcn-$ppn);
// $percent_data = array('0' => $percent_array , );

}


}

$percent_data = array('0' =>$data, '1' => $percent_array);
return $percent_data;


}

我想要百分比以及 ng-repeat 的数据

最佳答案

所以你的数据看起来像这样:

$scope.items = [
['Val1', 'Val2'],
['Val1', 'Val2']
];

您可以使用 2 个 ng-repeat 进行循环,如下所示:

<div ng-repeat="i in items">
<div ng-repeat="j in i">{{j}}</div>
</div>

Demo on JSFiddle

关于javascript - 具有多个数组的数组上的 ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41502608/

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