Angular 2表达式中的问号是什么意思? [英] What is the meaning of question mark in expressions in Angular 2?

查看:327
本文介绍了Angular 2表达式中的问号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

values?.listArray在这里是什么意思?我特别对问号感兴趣.

What does values?.listArray mean here? Specifically I am interested in the question mark.

[inputValue] = "values?.listArray"

推荐答案

编辑

自从原始答案以来,Ecmascript和Typescript(在3.7中)都添加了?.(称为可选链接运算符)运算符.有关详细信息,请参见 PR .

Since the original answer, Ecmascript, and Typescript (in 3.7) have both added the ?. (called the optional chaining operator) operator. See the PR for details.

原始答案

这不是Typescript运算符. Angular 2在模板中具有安全的导航操作符.

This is not a Typescript operator. Angular 2 has a safe navigation operator in templates.

values?.listArray

等同于

values != null ? values.listArray: null

更多信息此处此处

这篇关于Angular 2表达式中的问号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆