Skip to content

Instantly share code, notes, and snippets.

@kcmr
Created December 27, 2017 16:26
Show Gist options
  • Save kcmr/1d54726911af5ac75c30a673894b58b2 to your computer and use it in GitHub Desktop.
Save kcmr/1d54726911af5ac75c30a673894b58b2 to your computer and use it in GitHub Desktop.
Example of a two-way binding that has no effect on the host property // source https://jsbin.com/doqedej
<!doctype html>
<html>
<head>
<meta name="description" content="Example of a two-way binding that has no effect on the host property">
<base href="https://polygit.org/polymer+:master/webcomponents+:master/shadycss+webcomponents+:master/components/">
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="paper-toast/paper-toast.html">
</head>
<body>
<my-component></my-component>
<dom-module id="my-component">
<template>
<p>greeting: [[greeting]]</p>
<button on-click="_changeToastTextProperty">Change toast <code>text</code> value</button>
<paper-toast id="toast" text="{{greeting}}" opened duration="0"></paper-toast>
</template>
</dom-module>
<script>
HTMLImports.whenReady(() => {
Polymer({
is: 'my-component',
properties: {
greeting: {
type: String,
value: 'Hello'
}
},
_changeToastTextProperty: function() {
this.$.toast.text = 'something';
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment