zoukankan      html  css  js  c++  java
  • [Angular] The non-null assertion operator ( ! )

    When you use TypeScript's --strictNullChecks flag, you can prevent the type checker from throwing an error with Angular's non-null assertion operator, !.

    The Angular non-null assertion operator causes the TypeScript type checker to suspend strict null and undefined checks for a specific property expression.

    For example, you can assert that item properties are also defined.

    <!-- Assert color is defined, even if according to the `Item` type it could be undefined. -->
    <p>The item's color is: {{item.color!.toUpperCase()}}</p>

    Often, you want to make sure that any property bindings aren't null or undefined. However, there are situations in which such states are acceptable. For those situations, you can use Angular's non-null assertion operator to prevent TypeScript from reporting that a property is null or undefined.

    The non-null assertion operator, !, is optional unless you turn on strict null checks.

    For more information, see TypeScript's strict null checking.

  • 相关阅读:
    php高效率写法
    php经典bug
    cideogniter部署到阿里云服务器出现session加载错误
    linux gcc编译protocol
    linux权限问题
    http协议详解
    哈希表
    c语言函数
    socket相关函数
    构建之法阅读笔记05
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14678063.html
Copyright © 2011-2022 走看看