[英]How can you detect if Polymer is using Shady or Shadow DOM in Polymer Dart 1.0.0?
[英]How to detect that a polymer button has been clicked in the dart class
我希望能夠捕獲紙張按鈕上的click事件並更改“ clic me”文本。
我-module.html:
<dom-module id="my-module">
<template>
<paper-button>{{btnTxt}}</paper-button>
</template>
<script type="application/dart" src="my-module.dart"></script>
</dom-module>
我-module.dart:
@HtmlImport('my-module.html')
library blink.my_module;
import 'package:polymer/polymer.dart';
import 'package:web_components/web_components.dart' show HtmlImport;
@PolymerRegister('my-module')
class MyModule extends PolymerElement {
@property String btnTxt = "Clic me!";
MyModule.created() : super.created();
}
好的,您必須將其添加到以下文件中:
我-module.html:
//Adding the 'on-tap' tag with the dart methode name attribute, can also use 'on-click'
<paper-button on-tap="btnClicked">{{btnTxt}}</paper-button>
我-module.dart:
@PolymerRegister('my-module')
class MyModule extends PolymerElement {
@property String btnTxt = "Clic me!";
MyModule.created() : super.created();
//this method will listen for the linked event in the html
@reflectable
void btnClicked(Event e, [_]) {
set('btnTxt', btnTxt = 'Button Clicked!');
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.