简体   繁体   中英

Polymer property not updating via data binding

I have a Polymer 1.0 custom element that wraps a text box (an HTML input element). Here is the template:

<template>
    <input type="text" value="{{value}}">
</template>

And here is the value property:

 value: {
            type: String,
            value: '',
            notify: true,
            observer: '_valueChanged'
        }

As I type into the text box shouldn't the _valueChanged observer get invoked each time the input text is updated? The behaviour I'm encountering is that the observer only gets called once during initialisation of the custom element.

You need to bind as below. Read https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#two-way-native for more details.

<template>
    <input type="text" value="{{value::input}}">
</template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM