javascript - Based on angular js -


i have array called favouriteproducts=[deptname="",item:object(it contains product info pid,name,brand)] example

favouriteproducts[0]=deptname:"fresh food"                  item:object                      productid:4356178                     brand:brand_name  favouriteproducts[3]=deptname:"drinks"                  item:object                      productid:4356110                     brand:brand_name favouriteproducts[4]=deptname:"drinks"                  item:object                      productid:4356111                     brand:brand_name 

when display result ouput (using ng-repeat in html)

fresh food   productid:4356178 fresh food  productid:4356179 drinks  productid:43561710 drinks  productid:43561711 

but want output in way

fresh food  productid:4356178  productid:4356179 drinks  productid:43561710  productid:43561711 

can suggest me how this?? want array favouriteproducts[0]=deptname:"fresh food" item:object 0--> productid:4356178 brand:brand_name 1-->productid:4356179 brand:brand_name should appear. department name , respective products

you can add items array in following manner:

favouriteproducts[0]={deptname:"fresh food", item: {productid:4356178,brand:brand_name};  favouriteproducts[3]={deptname:"drinks",item:{productid:4356110,brand:brand_name}; favouriteproducts[4]={deptname:"drinks", item:{productid:4356111,brand:brand_name} 

then use ng-repeat in 2 div tags.

<div ng-repeat="dept in favouriteproducts.deptname"> <h3>{{dept}}</h3>     <div ng-repeat="item in dept.item">     {{item.productid}}     </div> </div> 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -