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
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:
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" />
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With