我想嵌入phone-component.html
另一个phone-view-component.html
自定义元素。在最后一列中phone-view-component.html
有一个“类型”、“提供者”、“数字”——所有文本——和一个按钮——“新建”。我想使用 phone-view-component 中的“New”按钮在第一行的每一行下添加一个由 a 和 ('Delete') 组成的<select>
phone - component <datalist>
。因此,每次我单击“新建”按钮时,都会插入一个新行。“删除”按钮将删除它所属的行。<tel>
<button>
到目前为止,我的尝试如下所示:
电话-component.html
<!DOCTYPE html>
<polymer-element name='epimss-phone-component'>
<template>
<roole src="reg-roole.rin" monitor="1"></roole>
<table border="1" width="100%">
<tbody>
<tr>
<td>
<select id="phoneCmbo" selectedIndex='{{phoneSelectedIndex}}' >
<option value="{{phone}}"
template repeat="{{phone in phones}}" >{{phone}}
</option>
</select>
</td>
<td>
<input id='providerTxt' type='text' value='{{phone.provider}}' list='providers'>
<datalist id='providers'>
<template repeat='{{provider in providers}}'>
<option value='{{provider}}'>{{provider}}</option>
</template>
</datalist>
</td>
<td><input id='num' type='tel' value='{{phone.num}}'>
</td>
<td>
<button id='deleteBtn on-click={{deleteRow}}'></button>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</template>
<script type="application/dart">
import 'package:polymer/polymer.dart' show CustomTag, PolymerElement, observable;
import 'dart:html' show Event, Node;
import 'package:epimss_polymer/reg_popo.dart' show Phone;
@CustomTag( 'epimss-phone-component' )
class PhoneElement extends PolymerElement
{
@observable Phone phone = new Phone();
List<String> phones = ['', 'Car', 'Fax', 'Home', 'Home Fax', 'Home Mobile',
'Home Video', 'Mobile', 'Pager', 'Work',
'Work Direct', 'Work Fax', 'Work Mobile', 'Work Video',
'Next-of-Kin Home', 'Next-of-Kin Mobile',
'Next-of-Kin Work', 'Tollfree', 'Web Phone'];
List<String> providers = [ '', 'AT&T', 'Digicel', 'Flow', 'Lime' ];
int providerSelectedIndex = 0;
//@observable Map phone = toObservable( new Phone() );
PhoneElement.created() : super.created();
void addRow( Event e, var detail, Node target)
{
print( 'New row created' );
}
void deleteRow( Event e, var detail, Node target)
{
print( 'Current row deleted' );
}
}
</script>
</polymer-element>
phone-view-component.html
<!DOCTYPE html>
<link rel="import" href="phone-component.html">
<polymer-element name='epimss-phone-view-component'>
<template>
<roole src="reg-roole.rin" monitor="1"></roole>
<table border="1" width="100%">
<tbody>
<tr>
<td><label id='typeLbl' for='typeDlst'>Type</label></td>
<td><label id='providerLbl' for='providerDlst'>Provider</label></td>
<td><label id='numberLbl' for='numberTxt'>Number</label></td>
<td><input id='newBtn' type='button' value='New' on-click='{{addRow}}'>
</tr>
</tbody>
</table>
<epimss-phone-component></epimss-phone-component>
</template>
<script type="application/dart">
import 'package:polymer/polymer.dart' show CustomTag, observable;
import 'dart:html' show Event, Node;
import 'package:roole_element/element.dart' show RooleElement;
import 'package:epimss_polymer/reg_popo.dart' show Phone;
@CustomTag( 'epimss-phone-view-component' )
class PhoneViewElement extends RooleElement
{
@observable Phone phone = new Phone();
PhoneViewElement.created() : super.created();
}
</script>
</polymer-element>
电话.dart
part of reg_popo;
class Phone extends Observable
{
String type = '';
String provider = '';
String num = '';
}
我不知道如何在每个表列中放置小部件并检索 List 模型中的每一行新数据。
任何帮助表示赞赏。谢谢