javascript - Having trouble using group by in angularJS -


Then I have this selection window that I want to group by 2 object array. My Subcategory- And Root-Category-Objects I Subclass has a relation id which is used to link root category ID. What do I want to do is group the subcategories with the original category name for the dropdown window. As of now, I only got it in the group of different relation IDs. Absolutely not use the original category. any advice?

From the HTML page;

  & lt; Div ng-controller = "categoryController" & gt; & Lt; Select ng-model = "$ parent.subCategoryObject" data-ng-option = "sub categories. Category for sub-categories of sub-categories in sub-categories." & Lt; Option value = "" & gt; Well N category & lt; / Option & gt; & Lt; / Select & gt; & Lt; / Div & gt;  

Controller.Jesus

  wikiControllers.controller ('categoryController', ['$ scope', 'categoryService', works ($ radius, category service) )) {CategoryService.getCategories () Then (function (data) {$ scope.rootCategories = data [0]; $ scope.subCategories = data [1]; $ scope.titles = data [2]; console.log ($ Scope.titles);});  

}];

You can add a code to $ scope For the example,

  $ scope.getRootCategoryName = function (id) {return $] by using the function  

Scope.rootCategories.filter (function (category) {return category.Id === ID;}) [0] .name; };

and:

  data-ng-option = "subcategories.subCategory group sub-categories getRootCategoryName (sub-categories.) For sub-categories " 

by: demo:


Comments