Fedy2
Fedy2

Reputation: 3207

How to get the selected menu item from the selection event for a paper-menu-button

I'm listening to the paper-menu-button selection through the on-core-select event.

  <paper-menu-button icon="menu" on-core-select="{{ selectedItem }}">
      <paper-item label="item 1"></paper-item>
      <paper-item label="item 2"></paper-item>
  </paper-menu-button>

In the Dart side:

  void selectedItem(event, detail, target) {
    print('SELECTED ${detail}');
  }

How can I get the selected item?

I've tried through the detail parameter but looks like an "empty" object (inspected through reflections and there are no relevant fields).

Upvotes: 1

Views: 387

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657298

print(detail['isSelected']); // ignore when false
print(item['detail'].label);

The debugger in WebStorm shows the items of an JavaScript object which is a nice feature.

Upvotes: 2

Related Questions