Hi.
I have a polymer core-menu with core items.
I would like to define which options should be vissible depends on user would by logged or not.
I think that it could be done by dynamic created CoreItems in dart like
CoreItem item=new CoreItem('core-item')
but i do not know how it could be added to core-menu defined in html,
Following is what i acctually have.
Please help and give me some advice.
dart:
@CustomTag('menu-element')
class Menu extends PolymerElement {
// Menu.created() : super.created();
@observable int isLogged;
Menu.created() : super.created()
{
if(window.localStorage['authentication'] !=null)
{
this.isLogged=1;
}
}
void SelectItem(event, detail, target)
{
if(detail['isSelected'])
{
var command=detail['item'].label;
print(detail['item'].label);
switch(command)
{
case 'Ogloszenia':
window.location.assign("index.html");
break;
case 'Logowanie':
window.location.assign("login.html");
break;
case 'Rejestracja':
window.location.assign("register.html");
break;
default:
print("Error");
}
}
}
}
html:
<polymer-element name="menu-element">
<template>
<core-menu on-core-select="{{SelectItem}}">
<core-item icon="dialog" label="Ogloszenia" id="advertisments"></core-item>
<core-item icon="settings" label="Logowanie" id="logon"></core-item>
<core-item icon="search" label="Rejestracja" id="register"></core-item>
<core-item label="Dodaj ogloszenie"></core-item>
</core-menu>
</template>
</polymer-element>