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
Can not use nested object method in expression for binding #6727
Comments
@webleaf NativeScript Core is supporting nested objects but is not supporting calling methods. Still, in the common case, you could write your Observable view model to work with properties and update the values you need to receive in the code-behind. For example this Playground demo - instead of calling the method export class HomeViewModel extends Observable {
private _message: string;
constructor() {
super();
// call this.fun() when needed to update the message property
this.fun();
}
fun() {
this.message = "This is so much Fun!";
}
get message(): string {
return this._message;
}
set message(value: string) {
if (this._message !== value) {
this._message = value;
this.notifyPropertyChange("message", value)
}
}
} As a side note NativeScript, do supports nested objects but they need to be created as an observables. vm.set("moreFun", fromObjectRecursive({ obj: {fun: "more fun!"}})) which can be used as follow: <Label textWrap="true" text="{{ moreFun.obj.fun }}" class="h2 description-label" /> |
@NickIliev in your example of |
I find workaround.
It works. But still it would be nice if this feature supported without such workaround. |
@webleaf you are right - marking this one as a feature request. |
can I take this issue ,please.I need a merged PR for my university assignment. |
You absolutely can @nadasuhailAyesh12 - feel free to post a PR referencing the issue if you would like to try it. |
Environment
To Reproduce
Same result if it used, as
ListView
itembindingContext
.Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: