Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PolymerDart custom element with two-way binding to Angular.dart model

I managed to two-way-bind my Angular.dart model to paper elements using the bind- syntax:

<paper-input bind-value="item.name"></paper-input>

Now I want to create a custom component that can expose a property for two-way binding:

@CustomTag('px-test')
class PxTest extends PolymerElement {

  @published
  var data = 1;
}

used like:

<px-test bind-data="item.data"></px-test>

The component gets rendered, and the data-field, referenced in the component template with {{data}} is rendered correctly, but the binding of data to item.data is not happening, i.e. if item.data is 55 the component still renders 1. Angular also tries to create the binding, a watch on item.data is created, but the changes are not propagated to PxTest.data What do I have to change in PxTest to make the binding happening?

Versions: Angular: 1.0, Polymer: 0.15.1+3

like image 324
Ozan Avatar asked Nov 08 '14 22:11

Ozan


People also ask

How to bind two-way data with ngmodel in Angular 2?

angular 2 provides us with a directive ngmodel to achieve two-way data binding. it is very simple and straightforward to use ngmodel directive, as shown in the listing below: to use ngmodel directive, we need to import formsmodule in the application:

What is the use of ngmodel directive in angular?

In Angular ngModel directive is used for two-way bindings. It simplifies creating two-way data bindings on form elements like input element. For example: <input type="text" [ (ngModel)]="userName" />

How to use ngmodel as property binding and Event binding separately?

Using bindon- we can use ngModel as follows. 4. If we want to use NgModel as property binding and event binding separately then we need to use ngModel and ngModelChange as follows. Here we will observe that the event name pattern will use Change as suffix.

How to change the color of text using ngmodel for two-way binding?

A default color initialized by component property will be selected initially in select box and a sample text is using that color. On change of color in select box, the color of text will change. Here we are using NgModel for two-way binding.


1 Answers

I don't know details about how binding between Angular.dart and Polymer.dart works but I suggest you try

//@published
@PublishedProperty(reflect: true)
var data = 1;

this way the DOM attribute gets updated too.

like image 105
Günter Zöchbauer Avatar answered Sep 21 '22 15:09

Günter Zöchbauer