2015-08-03 26 views

回答

1

這是非常相似Listen to events on ElementList with no explicit accessor。你可能需要一個不同的選擇器,但是你的問題沒有包含足夠的信息來知道可能是什麼。也許:

List<StreamSubscription> _clickSubscriptions = <StreamSubscription>[]; 
List<StreamSubscription> _changeSubscriptions = <StreamSubscription>[]; 

this.shadowRoot.querySelectorAll("input") 
.forEach((e) { 
    _clickSubscriptions.add(e.on["on-click"].listen((event) { 
    print("Event Triggered"); 
    })); 
    _changeSubscriptions.add(e.on["on-change"].listen((event) { 
    print("Event Triggered"); 
    })); 
}); 

取消訂閱使用

_clickSubscriptions.forEach((s) => s.cancel()); 
_changeSubscriptions.forEach((s) => s.cancel()); 

參見How can you assign mutliple listeners to a single StreamSubscription?

+0

感謝岡特,你總是非常有幫助 –

相關問題