本文介绍了与安全导航操作符的双向绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在带有安全导航操作符的 Angular 2 中使用双向绑定(语法糖)的最佳方法是什么.我尝试了以下方法.

What is the best way to use two-way-binding (syntax-sugar) in Angular 2 with the safe navigation operator. I've tried the following.

<input [(ngModel)]="x?.y?.z">

但这不受支持.

有没有办法使用某物.像这样吗?

Is there a way to use sth. like this?

推荐答案

你可以像这样拆分上下绑定

You can split up- and downwards-binding like

<input [ngModel]="x?.y?.z" (ngModelChange)="x?.y?.z ? x.y.z = $event : null">

这篇关于与安全导航操作符的双向绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 08:20