Skip to content

Support 2-way data binding (aka ng-model) #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tjvantoll opened this issue Jan 4, 2016 · 2 comments
Closed

Support 2-way data binding (aka ng-model) #27

tjvantoll opened this issue Jan 4, 2016 · 2 comments

Comments

@tjvantoll
Copy link

One of the first things I wanted to do in my {N} + Angular 2 app was add a simple form, but I found it difficult since <TextField [text]="foo"> only uses one-way data binding, and <TextField [(ngModel)]="foo"> doesn’t work.

Can we some up with some way to incorporate Angular 2’s two-way data binding, ideally with the same [(ngModel)] syntax?

Thanks.

@hdeshev
Copy link
Contributor

hdeshev commented Jan 4, 2016

[(ngModel)]="foo" desugars to [ngModel]="foo" (ngModelChange)="foo = $event", and we don't provide *Change events for most properties.

We could make this work for NativeScript dependency properties by attaching property change events automatically in the renderer whenever we get a fooChange event attach request.

This one needs more research, as I'm afraid we could easily end up with circular change events or zone exceptions (aka "causing a change during change detection").

@nsndeck
Copy link
Contributor

nsndeck commented Jan 27, 2016

@tjvantoll

After a #36 it is now possible to do two-way binding via '[ngModel]`. A sample usage should look similar to the following:

<Label [text]='model.test'></Label>
<TextField #name [ngModel]='model.test'></TextField>

Where model is {N} Observable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants