html - Google Polymer create menu tree -
I want to create a menu tree using the polymer core-menu. The table in my database is:
The table has a category with sub category. I want to show it as a menu tree, I did something like this:
& lt; Polymer-element name = "category-list" attributes = "show" & gt; & Lt; Templates & gt; & Lt; Style & gt; : Host {Display: Block; Width: 100%; } .cat_item {margin: 10px; Background color: RGB (255, 255, 255); } & Lt; / Style & gt; & Lt; Category-service id = "service" categories = "{{categories}}" & gt; & Lt; / Category-services & gt; & Lt; Selected core-menu = "1" selected index = "1" id = "core_menu" & gt; & Lt; Template repeat = "{{category in categories}}" id = "t" if = "category.has_child == '1'" & gt; & Lt; Core-Submenu label = "{{category.category_name}}" icon = "settings" value = "name" category = "cat_itum" & gt; & Lt; Template ref = "t" repeat = "{{range in categories}} = if =" category.parent_id! = '0' "> but I can not use "if", I do something wrong. I need to display the sub item using the Database table field Example:
if (category Has_child == ' 1 ') // display if (category.parent_id! = 0) // display I found the official example:
But this is not what I want, so please help me solve this task.
If this is your original code then one mistake is that you If the attribute's value is not placed in double-muse, then it should be
& lt; Template repeat = "{{range in categories}}" = "{= class = has_child == '1'}}" id = "t" & gt; In addition, there are examples in if = "{{conditionalValue}}" note it taht Says conditional value , expression is not. So maybe just try & lt; Repeat template = "{{range in categories}}" if = "{{category.has_child}}" id = "t" & gt; and make sure that the value of category.has_child is a velar which is true only for categories that are child.
Comments
Post a Comment