加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 2模板 – 方法的安全导航操作符

发布时间:2020-12-17 07:17:47 所属栏目:安全 来源:网络整理
导读:我正在成功使用angular 2安全导航操作符作为属性,文档说明属性路径,但方法路径的最佳方法是什么? myObj?.myMethod().myProperty 给出例外: EXCEPTION: TypeError: Cannot read property ‘myProperty’ of null in [{{myObj?.myMethod().myProperty}} 在ja
我正在成功使用angular 2安全导航操作符作为属性,文档说明属性路径,但方法路径的最佳方法是什么?
myObj?.myMethod().myProperty

给出例外:

EXCEPTION: TypeError: Cannot read property ‘myProperty’ of null in
[{{myObj?.myMethod().myProperty}}

在javascript中,引自 w3schools:

A JavaScript method is a property containing a function definition.

我没有看到任何问题,为什么它不应该像这样工作:

{{myObj?.myMethod()?.myProperty}}

从Angular.io cheat sheet开始:

<p>Employer: {{employer?.companyName}}</p>

The safe navigation operator (?) means that the employer field is optional and if undefined,the rest of the expression should be ignored

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读