Home>Article>Web Front-end> What are the uses of "?" and "!" in Angular?

What are the uses of "?" and "!" in Angular?

青灯夜游
青灯夜游 forward
2020-09-10 10:11:12 12832browse

What are the uses of

Related tutorial recommendations: "angularjs tutorial"

?Used When checking whether the variable before the question mark is null or undefined, the program will not make an error.

stu2: Student = { id: 1, name: undefined, age: 3 }; 

stu2 name {{stu2!.name}}

// stu2 name

stu2 id {{stu2!.id}}

// stu2 id 1

!Used to check that the program will not make an error when the variable after the exclamation mark is null or undefined.

stu3: Student; 

stu3 id{{stu3?.id}}

// stu3 id

stu3 name{{stu3?.name}}

// stu3 name

For more programming-related knowledge, please visit:Introduction to Programming! !

The above is the detailed content of What are the uses of "?" and "!" in Angular?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete