method bindProperty


Bindable bindProperty(Symbol name, bindableOrValue, {oneTime: false})

Bind the name property in this element to bindable. Note in Dart it is necessary to also define the field:

var myProperty;

ready() {
  super.ready();
  bindProperty(#myProperty,
      new PathObserver(this, 'myModel.path.to.otherProp'));
}

Source

Bindable bindProperty(Symbol name, bindableOrValue, {oneTime: false}) {
  // Dart note: normally we only reach this code when we know it's a
  // property, but if someone uses bindProperty directly they might get a
  // NoSuchMethodError either from the getField below, or from the setField
  // inside PolymerBinding. That doesn't seem unreasonable, but it's a slight
  // difference from Polymer.js behavior.

  _bindLog.fine(() => 'bindProperty: [$bindableOrValue] to [$_name].[$name]');

  if (oneTime) {
    if (bindableOrValue is Bindable) {
      _bindLog.warning(() =>
          'bindProperty: expected non-bindable value n a one-time binding to '
          '[$_name].[$name], but found $bindableOrValue.');
    }
    smoke.write(this, name, bindableOrValue);
    return null;
  }

  return bindToAccessor(name, bindableOrValue, resolveBindingValue: true);
}