我有以下抽屜形式分量動態創建
抽屜form.html
<!DOCTYPE html>
<link rel="import" href="../../../packages/polymer/polymer.html">
<link rel="import" href="../../../packages/paper_elements/paper_icon_button.html">
<polymer-element name='drawer-form'>
<template>
<section id='reg' layout horizontal center>
<paper-icon-button
icon="menu"
id='menu_icon'
on-click='{{clickHandler}}'>
</paper-icon-button>
<h4 id='regLbl'>New Patient</h4>
</section>
</template>
<script type="application/dart">
import 'package:polymer/polymer.dart';
import 'dart:html';
@CustomTag('drawer-form')
class DrawerForm extends PolymerElement {
@observable bool state = false;
DrawerForm.created() : super.created();
void clickHandler() {
fire('CREATE_NEW_PATIENT');
}
}
</script>
</polymer-element>
抽屜形式是在用於核 - 抽屜面板的主窗口中的新標籤主要形式組成:
主form.html
<!DOCTYPE html>
<link rel="import" href="../../../packages/polymer/polymer.html">
<link rel="import" href="../../../packages/core_elements/core_drawer_panel.html">
<link rel="import" href="../../../packages/core_elements/core_icon_button.html">
<link rel="import" href="../../../packages/core_elements/core_toolbar.html">
<link rel="import" href="../../../packages/paper_elements/roboto.html">
<link rel="import" href="../../../packages/core_elements/core_toolbar.html">
<link rel="import" href="../../../packages/paper_elements/paper_icon_button.html">
<link rel="import" href="../../../packages/fontawesome_elements/fontawesome_icon.html">
<link rel="import" href="drawer-form.html">
<polymer-element name="main-form">
<template>
<core-drawer-panel id="core_drawer_panel">
<section id="drawer" drawer>
<drawer-form></drawer-form>
</section>
<section id="main" main>
<core-toolbar id="core_toolbar">
<paper-icon-button
icon="menu"
id='menu_icon'
on-click='{{menu_icon_handler}}'>
</paper-icon-button>
<div id="div" flex>Toolbar</div>
</core-toolbar>
<section id='content'></section>
</section>
</core-drawer-panel>
</template>
<script type="application/dart">
import 'package:polymer/polymer.dart';
import 'dart:html';
import 'package:core_elements/core_drawer_panel.dart';
@CustomTag('main-form')
class MainForm extends PolymerElement {
CoreDrawerPanel drawerPanel;
MainForm.created() : super.created();
void toggleDrawer() {
bool state = drawerPanel.narrow;
}
void menu_icon_handler() {
bool state = drawerPanel.narrow;
print (state);
}
@override
void attached() {
super.attached();
drawerPanel = $['drawerPanel'] as CoreDrawerPanel;
}
}
</script>
</polymer-element>
drawer-form.html中的clickHandloer會觸發「CREATE_NEW_PATIENT」事件。我如何在主窗體組件中捕獲此事件以便創建新病人?
這將是非常有益的,如果你可以從所有剝離代碼不需要重現問題的零件(空行,樣式標籤,不需要重現問題的標籤)。 –